tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Souther <bsout...@fwdco.com>
Subject Re: Detail: How to cache the user's input in a jsp page?
Date Thu, 04 Sep 2003 12:27:08 GMT
Ahh,

The problem is that you're not submitting the form. You're making a new 
request via Javascript.

Instead, do this:
Give the form an id:
<form method="post" name="form1" id="form1">


Then in your select box use javascript to subit the form.

<select name="item_num" onChange="document.getElementById('form1').submit()">


Then you'll be able to read the submitted form information from the request 
object.  You also won't need to put all the querystring building code in the 
option tags.







On Thursday 04 September 2003 07:58 am, engp0510 wrote:
> Hi , ALL,
> The following is my jsp page, store it into a file named "MyQUESTION.jsp" ,
> pay attention for the "Subjuect" while u choosing the select.
>
> <%
>    int item_num = 5;
>    int row_num  = 1;
>    if(request.getParameter("_rows")!=null){
>       String rowstr = (request.getParameter("_rows"));
>       try{
>          row_num = Integer.parseInt(rowstr);
>       }
>       catch(NumberFormatException ne){}
>    }
>
> %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> <html>
> <head>
>
> </head>
> <center>
> <body>
>
> <table border="0" cellpadding="0" width="100%" cellspacing="0"
> bordercolor="#FFFFFF" height="384"> <TR><TD align=right height=279>
>       <FORM name=form1 action="/operator" method=post>
>
>       <TABLE cellSpacing=1 width="100%" border=1 height="261" align="left">
>         <TBODY>
>         <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>
>
>         <TR class="LGREY">
>           <TD class="L" align=right width="100%"   colspan="2">
>           <table cellSpacing=0 width="100%" border=1 align="left"
> bordercolor="#cccccc"> <tr>
>               <td width="25%" align="center">
>               <select size="1" name=item_num
> ONCHANGE="location=this.options[this.selectedIndex].value;"> <%for(int
> i=1;i<=5;i++){%>
>                <option
> value="\MyQUESTION.jsp?_rows=<%=i%>"<%if(row_num==i){out.print("SELECTED");
>}%> >-<%=i%>-</option> <%}%>
>                 </select>
>
>
>               </td>
>               <td width="25%" align="center"><b>Project Detail</b></td>
>               <td width="25%" align="center"><b>Quantity</b></td>
>               <td width="25%" align="center"><b>Unit Price( S$)</b></td>
>             </tr>
>             <%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>
>
>            <%}%>
>           </table>
>         </TD></TR>
>         </TBODY>
>       </TABLE></TD></TR>
>
>   <TR>
>     <TD class="L" align=right height=25>
>       <P align=center><input type=submit value=" Create">
>       <input type=submit value="  Clear 
> "></P></TD></TR></TBODY></TABLE></FORM></CENTER>
>
> </BODY>
> </HTML>

-- 
Ben Souther
F.W. Davison & Company, Inc.



REGISTER NOW FOR THE SCORPEO USER CONFERENCE!
September 18-19, 2003 in Boston/Brookline, MA
Additional Training Sessions held September 17, 2003
More info >> http://www.fwdco.com/services/Uconf03/default.shtm


Mime
View raw message