• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Struts 1.3: request attributes lost after submit

Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two jsp page, say form.jsp and myForm.jsp.

In the first page, form.jsp, there is a radio button group (the form name is "form").
When the user submits this form, some info are retrieved from a db and with these informations the form in myForm.jsp is built (the form name is "myForm").
The problem is that when this second form is submitted, only the errors are displayed but not the form fields created from db values.
For example, I retrieve from database labels and values for two radio buttons (property="prop").
In struts-config.xml, I have:

<form-bean name="myForm" type="org.apache.struts.validator.MyValidatorActionForm">
<form-property name="prop" type="java.lang.Integer"></form-property>
<action path="/form" input="/jsp/home.jsp" name="form"
scope="request" type="myPackage.LoadInfo">
<forward name="Success" path="/jsp/myForm.jsp"/>
<forward name="Failure" path="/jsp/home.jsp" />

<action path="/myForm" input="/jsp/myForm.jsp" name="myForm" validate="true" scope="request" type="myPackage.MyValidatorAction">
<forward name="Success" path="/jsp/success.jsp"/>
<forward name="Failure" path="/jsp/failure.jsp"/>

In myForm.jsp:

<html:form action="/myForm">
<div><label>* <bean:message key="myForm.label"/></label>
<c:forEach var="propTypes" items="${props}">
<html:radio property="prop" value="${propTypes.value}">${propTypes.label}
  <html:errors property="prop" />
<div><html:submit><bean:message key="myForm.label2"/></html:submit></div>

In validation.xml:

<form name="/myForm">
<field property="prop" depends="required">
<arg key="myForm.label"/>

After the form submit without select any radio button, the error is displayed, but not the radio buttons.

How could I maintain all the request attributes?
I tried to use scope session too, but nothing has changed:

<action path="/myForm" input="/jsp/myForm.jsp" name="myForm" validate="true" scope="session" type="myPackage.MyValidatorAction">
<forward name="Success" path="/jsp/success.jsp"/>
<forward name="Failure" path="/jsp/failure.jsp"/>

I resolved by using:

request.getSession().setAttribute("props", props);

in the Action LoadInfo called before the display of the form.

In myForm.jsp I use:


Instead in the struts-config.xml, the scope remains request.

Nevertheless, this isn't a good solution, 'cause different browser tabs share the same session.

How could I resolve this issue?
Look! It's Leonardo da Vinci! And he brought a tiny ad!
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic