Been getting this error, and I've tried everything I can think of to get around it. It seems to be a problem with my ActionForm class, but I can't figure out what it is! The Action class is "SubmitAction", and the ActionForm is "SubmitForm". Help me please, if you can.
struts-config.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<struts-config>
<!-- ========== Form Bean Definitions ================= -->
<form-beans>
<form-bean name="submitForm"
type="hansen.playground.SubmitForm"/>
</form-beans>
<!-- ========== Action Mapping Definitions ============ -->
<action-mappings>
<!-- Submit Artwork -->
<action path="/submit"
type="hansen.playground.SubmitAction">
name="submitForm"
input="/submit.jsp"
scope="request">
<forward name="success" path="/main.jsp"/>
<forward name="failed" path="/blah.jsp"/>
</action>
</action-mappings>
</struts-config>
SubmitAction.java:
package hansen.playground;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public final class SubmitAction extends Action {
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
SubmitForm f = (SubmitForm) form; // get the form bean
//create a new ArtBean from the form input and the username from the UserBean in the session
HttpSession session = request.getSession();
String artist = ((UserBean)session.getAttribute("user")).getUserName();
//ArtBean artwork = new ArtBean(f.getTitle(), artist, f.getArtUrl(), f.getDescription());
//enter data into database
//artwork.submit();
//Forward control to the next target
return (mapping.findForward("success"));
}
}//class
SubmitForm.java:
package hansen.playground;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
public final class SubmitForm extends ActionForm {
/* Title */
private String title = null; // default value
public String getTitle() {
return (this.title);
}
public void setTitle(String inTitle){
this.title = inTitle;
}
/* artUrl */
private String artUrl = null; // default value
public String getArtUrl() {
return (this.artUrl);
}
public void setArtUrl(String inArtUrl) {
this.artUrl = inArtUrl;
}
/* description */
private String description = null; // default value
public String getDescription() {
return this.description;
}
public void setDescription(String inDescription) {
this.description = inDescription;
}
}
submit.jsp:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head><title>Submit Page</title></head>
<body>
<%@ include file="navbar.jsp" %>
<h3>Submit Art</h3>
<logic:notPresent name="user" property="userName" scope="session">
You are not
logged in!<br>
</logic:notPresent>
<logic:present name="user" property="userName" scope="session">
<html:form action="submit.do">
<TABLE border="0">
<tr><td>Title:</td><td><html:text property="title"/></td></tr>
<tr><td>URL:</td><td><html:text property="artUrl"/></td></tr>
<tr><td>Description:</td><td><html:textarea property="description"/></td></tr>
<TABLE>
<html:submit/>
</html:form>
</logic:present>
</body>
</html>