I have been following this
struts tutorial verbatim:
http://javaboutique.internet.com/tutorials/Struts/ First of all, I'm using jakarta-struts 1.2.4, and
tomcat 5.5.7, with jdk 1.5.0.
It's supposed to be relatively simple.
The example involves creating a web form, associating it with an ActionForm, and using an Action to process the request from the form.
The Action involves updating a request parameter and returning success.
<!-- SubmitForm which extends ActionForm -->
public final class SubmitForm extends ActionForm
{
private
String lastName = "Mbadiwe";
private String firstName;
private String address;
private String sex;
private String married;
private String age;
}
<!-- SubmitAction which extends Action -->
public class SubmitAction extends Action
{
public ActionForward perform( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response )
{
SubmitForm f = (SubmitForm) form;
String lastName = f.getLastName();
request.setAttribute( "lastName", lastName.toUpperCase() );
return ( mapping.findForward( "success" ) );
}
}
These classes are compiled and kept under WEB-INF/classes.
Now, for the struts-config.xml mapping. I will just include the relevant parts.
<form-beans>
<form-bean name="submitForm" type="com.firstbean.bean.SubmitForm" />
</form-beans>
<action-mappings>
<action path="/submit" type="com.firstbean.bean.SubmitAction" name="submitForm" input="/submit.jsp" scope="request">
<forward name="success" path="/submit.jsp" />
<forward name="failure" path="/submit.jsp" />
</action>
</action-mappings>
And of course, the web form:
<%@ page language="java" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html>
<head><title>Submit Example</title></head>
<body>
<h2>My Submit Page</h2>
<html:errors/>
<html:form action="submit.do">
First name: <html:text property="firstName" /> Last name: <html:text property="lastName" />
<br/><br/>
Address: <html:text property="address" /><br/><br/>
Sex: <html:radio property="sex" value="M"/>Male
<html:radio property="sex" value="F"/>Female<br/><br/>
Married: <html:checkbox property="married" /><br/><br/>
Age: <html:select property="age">
<html:option value="a">0-19</html:option>
<html:option value="b">20-49</html:option>
<html:option value="c">50-</html:option>
</html:select><br/><br/>
<html:submit />
</html:form>
</body>
</html>
Now, everything compiles and I don't have any tomcat errors. But whenever I click submit, all I get is a link to 'submit.do' which has nothing but a blank page.
Please can anybody help? I don't see any error messages that could point me in the write direction. Also does anybody have tips for debugging struts applications?
Thanks in advance.