You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by BH...@powersystems.rockwell.com on 2005/09/06 17:34:34 UTC

Re: request attribute in jsp - please advice

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.



                                                                           
             "Rivka Shisman"                                               
             <rivka@nite.org.i                                             
             l>                                                         To 
                                       "Struts Users Mailing List"         
             09/06/2005 12:27          <us...@struts.apache.org>            
             PM                                                         cc 
                                                                           
                                                                   Subject 
             Please respond to         request attribute in jsp - please   
               "Struts Users           advice                              
               Mailing List"                                               
             <user@struts.apac                                             
                  he.org>                                                  
                                                                           
                                                                           
                                                                           




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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org