wood burning stoves 2.0*
The moose likes Servlets and the fly likes doubt in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "doubt in servlet" Watch "doubt in servlet" New topic
Author

doubt in servlet

Chak Terlapu
Ranch Hand

Joined: Oct 20, 2000
Posts: 32
Hi
I am using servlets to connect to a database and display it in the form of HTML table. I need to assign a radio button to each row, keeping in mind that this a big table containing around 100 rows. THe radio button should be a column before "Name". How can I assign a radio button to each row
without doing 100 times like
<input type=radio name="id" value="1"> for each row because I am using result set to display the table.

Any help would be greatly appreciated
Thanks
Robert Brunner
Ranch Hand

Joined: Jul 18, 2001
Posts: 49
Try doing it in JSP. You can set up a loop to itereate over the result set and print out the html as you want.
Chak Terlapu
Ranch Hand

Joined: Oct 20, 2000
Posts: 32
Hi,
I have never used JSP before. Could you tell me where I can find related information so that I could get started on it.
Thanks for your help
Chak
Samuel Clemens
Greenhorn

Joined: Aug 13, 2001
Posts: 4
If you want to continue using a servlet, just put that line of code for the button into your while loop. If you need unique names for each, just use a counter and have the counter value appear as part of the button name, and then increment the counter at the end of each loop iteration.
SC
Samuel Clemens
Greenhorn

Joined: Aug 13, 2001
Posts: 4
Something like the following might be good!
int counter = 1
while(rs.next()){
out.println("<input type=radio name='id'" + counter +
" value='1'>");
out.println("<TR>");
out.println("<TD>" + rs.getString("NAME") + "</TD>");
out.println("<TD>" + rs.getString("PHONE") + "</TD>");
out.println("<TD>" + rs.getString("ADDRESS") + "</TD>");
out.println("<TD>" + rs.getString("ADDRESS") + "</TD>");
out.println("</TR>");
counter++;
}
Chak Terlapu
Ranch Hand

Joined: Oct 20, 2000
Posts: 32
Hi,
Thanks for the help, but isn't it the value that should be changing and the name same for all the radio butons . When we do request.getParameter(id) in another servlet then I think we will get the value of the radio button according to which the row info is obtained. I am new to this. Please correct me if it is wrong assumption.

Thanks
Chak
Something like the following might be good!
Samuel Clemens
Greenhorn

Joined: Aug 13, 2001
Posts: 4
Yes, possibly. I haven't been using that stuff lately. But as long as you see my general direction, the rest should follow.
Good luck.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: doubt in servlet
 
Similar Threads
Problem Passing Parameter values to action
Problem in hiding the row of data
Strange problem ??
JSP returning old data, database was changed correctly!
MS-Access Problem