Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Text Boxes and JSP

 
tejaswini vasist
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why the try/catch block on the page? This is a poor practice.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic