wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 60774
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Consider Paul's rocket mass heater.
 
subject: Text Boxes and JSP
 
Similar Threads
how to connect to database and display query vqlus using proper java/jsp
JSP Help Regarding the Radio Button
Objects in JSP
jsp - checkbox information retieval problem
What happen to this Tabbed form ?