File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Text Boxes and JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Text Boxes and JSP" Watch "Text Boxes and JSP" New topic
Author

Text Boxes and JSP

tejaswini vasist
Greenhorn

Joined: Apr 10, 2004
Posts: 17
I have a JSP in which the text boxes are generated based on the no of items present in the database.How do i make the name of each text box unique.Also how do i retrieve the values of these text boxes in the servlet .
My JSP code is :

try {
for (int i=0; i<numberOfItems; i++)
{
%>
<tr>

<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%">
<input type="hidden" name="id"+ i> <%=items.ItemID[i]%> </td>
<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%"><%=items.ItemName[i]%></td>
<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%"><%=items.Price[i]%></td>
<td bgcolor=lightsteelblue><font face="verdana, arial, helvetica" size="2" width="20%">
<input type="text" name="quant" + i maxlen=3 visibility="false"></td>
</tr>
<% }
} catch(Exception e)
{
System.out.println(e.getMessage());
}
%>

Is the syntax correct ? Also i want to know how to get these values in
the servlet.
Kaustubh Patil
Ranch Hand

Joined: Aug 13, 2001
Posts: 164
Well...
just copying a part of your code.. with little modifications..

I think you can fill in the gaps.. notice the <%=i%> thing.
also to retrieve the values

[ April 16, 2004: Message edited by: Kaustubh Patil ]

Kaustubh. Mumbai, India.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Why the try/catch block on the page? This is a poor practice.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: Text Boxes and JSP