• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

doubt in servlet

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic