Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Populating an HTML option list from a resultset

 
Kevin Currie
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Anyone know how to populate an HTML form option list from a JDBC resultset?
Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my version of the 2,679 ways this could be done: (in other words, here's how I'd do it):
1) The controller servlet for the request would interact with a model-level class that abstracts the list. Returned would be an array list or other structure containing the name-value pairs for the options list. The JDBC is completely performed in the model class.
2) The controller would place this list on the request as an attribute, then forward to the JSP page for the view.
3) The JSP page would use the JSTL forEach tag to iterate over the list and construct the HTML for the options.
Notice that each tier of the MVC architecural patterm comes into play.
[ February 16, 2004: Message edited by: Bear Bibeault ]
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of several FormattedDataSet signatures available. Others take ResultSet's and display multiselect, and regular listboxes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic