Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts 1.3: request attributes lost after submit  RSS feed

Fran Cricket
Posts: 9
  • Mark post as helpful
  • send pies
  • 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?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!