The problem is that you are loading a new page through javascript without sending the 
other data fields from the current page in the request.

This is entirely a javascript processing problem. To actually make this work without a 
lot of re-engineering, make OnChange for the select box call a javascript function 
that either collects the rest of the data from the form and adds it in the form of a 
get request to the URL that comes from the value of the select option; or change the 
action target for the form to the value of the select option and submit the form.

The real trick is to get the rest of the data included into the request so that the 
next page has the data to work with.

-----Original Message-----
From: engp0510 [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 04, 2003 4:43 AM
To: Tomcat Users List
Subject: Re: How to cache the user's input in a jsp page?


Thanks
But it is nothing with "form" and "request".
Maybe I should make me more clear:


For the first time this JSP loaded, it is not sure how many rows of a table
needed by user. Then user choos a select_box to set the rows number and then
JSP was reloaded with table contain the number of rows user selected.


           <select size="1" name=item_num
ONCHANGE="location=this.options[this.selectedIndex].value;">
               <%for(int i=1;i<=5;i++){%>
               <option
value="\AddQuotation.jsp?actionfrom=<%=request_from%>&row_num=<%=i%>"<%if(ro
w_num==i){out.print("SELECTED");}%> >-<%=i%>-</option>
               <%}%>
               </select>


But user may set other fields before setting the number of rows, so when the
JSP was reloaded, all filled fields ahould be cached, is it possible?




----- Original Message ----- 
From: "Kwok Peng Tuck" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Thursday, September 04, 2003 4:31 PM
Subject: Re: How to cache the user's input in a jsp page?


> In the servlet or jsp you could do :
> String text =  request.getParameter("subject") ;
>
> Then do whatever you want with it.
>
> engp0510 wrote:
>
> >Thanks
> >I know maybe I should use session, but when I choose "select" box, the
jsp
> >page will be reloaded. How do I save the value of "<INPUT tabIndex=1
> >maxLength=100 size=40 name=subject>" into session, that after reloaded
the
> >value should be the same as user input previously?
> >
> >----- Original Message ----- 
> >From: "Duncan Strang" <[EMAIL PROTECTED]>
> >To: "Tomcat Users List" <[EMAIL PROTECTED]>
> >Sent: Thursday, September 04, 2003 4:15 PM
> >Subject: RE: How to cache the user's input in a jsp page?
> >
> >
> >Check out JSP's implicit object collection
> >
> >For example, if you are using user sessions you can put any Object onto
> >the session, this will then be available whenever the user accesses the
> >page.
> >To use the session object simply use
> >
> >session.setAttribute("identifier", Object);
> >
> >So to save an Integer (Objects only, not primitives) for example
> >
> >Integer foo = new integer(10);
> >session.setAttribute("fooint" foo);
> >
> >To retrieve it next request use
> >
> >Integer foo2 = (Integer)session.getAttribute("fooint");
> >
> >There are other implicit Objects including application (the jsp view of
> >the Servlet context) but this is globally visible so shouldn't be use to
> >store session type variables (IMHO)
> >
> >Or you could write your own cache :)
> >
> >Cheers
> >Duncan
> >
> >
> >-----Original Message-----
> >From: engp0510 [mailto:[EMAIL PROTECTED]
> >Sent: 04 September 2003 09:00
> >To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> >Subject: How to cache the user's input in a jsp page?
> >
> >
> >Hi
> >How to cache the user's input in a jsp page? The following is some code
> >of my JSP:
> >
> ><%
> >   int item_num = 5;
> >   int row_num  = 1;
> >   if(request.getParameter("row_num")!=null){
> >      String rowstr = (request.getParameter("row_num"));
> >      try{
> >         row_num = Integer.parseInt(rowstr);
> >      }
> >      catch(NumberFormatException ne){}
> >   }
> >%>
> >...................
> >...................
> >        <TR class="LGREY">
> >          <TD class="L" align=right width="25%"  >Subject&nbsp; : </TD>
> >          <TD class="L" width="75%"  >&nbsp;
> >              <INPUT tabIndex=1 maxLength=100 size=40 name=subject>
> >          </TD>
> >        </TR>
> >
> >
> >..................
> >              <select size="1" name=item_num
> >ONCHANGE="location=this.options[this.selectedIndex].value;">
> >               <%for(int i=1;i<=5;i++){%>
> >               <option
> >value="\AddQuotation.jsp?actionfrom=<%=request_from%>&row_num=<%=i%>"<%i
> >f(row_num==i){out.print("SELECTED");}%> >-<%=i%>-</option>
> >               <%}%>
> >                </select>
> >....................
> >...................
> >           <%for(int ii=0;ii<row_num;ii++){%>
> >            <tr>
> >              <td width="25%" align="center"  ><%=ii+1%></td>
> >              <td width="25%" align="center"  >
> >                  &nbsp;<INPUT tabIndex=2 maxLength=100 size=25
> >name=project_detail_<%=ii+1%>></td>
> >              <td width="25%" align="center"  >
> >                  &nbsp;<INPUT tabIndex=2 maxLength=20 size=10
> >name=quantity_<%=ii+1%>></td>
> >              <td width="25%" align="center" >
> >                  &nbsp;<INPUT tabIndex=2 maxLength=20 size=10
> >name=unit_price_<%=ii+1%>></td>
> >            </tr>
> >
> >           <%}%>
> >
> >The choosing of select will refresh this jsp and create the rows as many
> >as choosed. But how to cache the input of "Subject"?
> >
> >???? email:       <INPUT NAME="email"
> >onChange="checkEmail(this.value)"><BR>
> >
> >Can I do this without using javascript?
> >
> >________________________________________________________________________
> >This email has been scanned for all viruses by the MessageLabs Email
> >Security System. For more information on a proactive email security
> >service working around the clock, around the globe, visit
> >http://www.messagelabs.com
> >________________________________________________________________________
> >
> >________________________________________________________________________
> >This email has been scanned for all viruses by the MessageLabs Email
> >Security System. For more information on a proactive email security
> >service working around the clock, around the globe, visit
> >http://www.messagelabs.com
> >________________________________________________________________________
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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


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

Reply via email to