• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Frustration with struts. Please help!!!

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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="submit.do">
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">
<html:option value="a">0-19</html:option>
<html:option value="b">20-49</html:option>
<html:option value="c">50-</html:option>
<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 '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
  • 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.
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
  • 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.
Posts: 9
  • Mark post as helpful
  • send pies
  • 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.
Let me tell you a story about a man named Jed. He made this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic