if you store the request attribute in a hidden field on the screen, when the page is submitted the field will be put back into the request. Otherwise, you will need to move the field to the session where it will not be cleared when the request is invalidated after the JSP is displayed.

Inactive hide details for "Rivka Shisman" <[EMAIL PROTECTED]>"Rivka Shisman" <[EMAIL PROTECTED]>


          "Rivka Shisman" <[EMAIL PROTECTED]>

          09/06/2005 12:27 PM

          Please respond to
          "Struts Users Mailing List" <user@struts.apache.org>

To

"Struts Users Mailing List" <user@struts.apache.org>

cc


Subject

request attribute in jsp - please advice

Hello friends

I have an EditStudent.jsp page in which I have a form. Before the form
tag I get a request attribute called 'listIndex'. But, when my
validate() method fails on field validation it returns back to the above
mentioned jsp page with an appropriate message. That is o.k. - the
problem is that this causes the removal of the request attribute that
was originally set by the EditStudentAction.

So what I do now in the jsp page is something like this:

<% int listIndex = 0;

     If (request.getAttribute("index") != null){

           listIndex = request.getAttribute("index");

     }else{

            If (request.getParameter("myIndex") != null){

                       listIndex = request.getParameter("myIndex");

           }

%>

And then under the <html:form> I have an hidden input like:

<INPUT type="hidden" name="myIndex" value=<% =listIndex%>

When the validate{} fails the - getParameter("myIndex") - enables me to
restore my request attribute via the hidden parameter.

Do you know a nicer way to do it?



Thanks

Rivka




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to