File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Frustration with struts. Please help!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Frustration with struts. Please help!!!" Watch "Frustration with struts. Please help!!!" New topic

Frustration with struts. Please help!!!

Anthony McHenry.

Joined: Mar 16, 2003
Posts: 9
I have been following this struts tutorial verbatim:

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-bean name="submitForm" type="com.firstbean.bean.SubmitForm" />

<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" />

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" %>

<head><title>Submit Example</title></head>
<h2>My Submit Page</h2>
<html:form action="">
First name: <html:text property="firstName" />  Last name: <html:text property="lastName" />
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">
<htmlption value="a">0-19</htmlption>
<htmlption value="b">20-49</htmlption>
<htmlption value="c">50-</htmlption>
<html:submit />

Now, everything compiles and I don't have any tomcat errors. But whenever I click submit, all I get is a link to '' 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.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
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.

Joined: Mar 16, 2003
Posts: 9
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

Joined: Dec 08, 2004
Posts: 111

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.

Joined: Mar 16, 2003
Posts: 9
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.
I agree. Here's the link:
subject: Frustration with struts. Please help!!!
It's not a secret anymore!