• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Frustration with struts. Please help!!!

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to struts. But I will give a try.

Shouldn't your html:form action value "/submit" match your action-mapping path attribute "/submit".
 
Anthony McHenry.
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I modified the submit.jsp file as such:
<html:form action="/submit">

However, I had the same result: a blank page.
Thanks for your help on both posts. It is much appreciated.
 
Ranch Hand
Posts: 111
Mac Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anthony,

I can suggest something for debugging.

First change the content of submit.jsp to display only welcome.

If still it shows blank page then you are not going to your jsp page.

So there is some problem before jsp, i.e in action.

Use print statement to print some value to console.

Hope this helps!
 
Anthony McHenry.
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help Sanat.
I found out what the problem was. I was using the deprecated perform function in my Action class. In current versions of struts, the execute function is used instead.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic