wood burning stoves 2.0*
The moose likes JDBC and the fly likes Populating an HTML option list from a resultset 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 » Databases » JDBC
Bookmark "Populating an HTML option list from a resultset" Watch "Populating an HTML option list from a resultset" New topic
Author

Populating an HTML option list from a resultset

Kevin Currie
Greenhorn

Joined: Feb 02, 2004
Posts: 2
Hi,
Anyone know how to populate an HTML form option list from a JDBC resultset?
Thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 860
One of several FormattedDataSet signatures available. Others take ResultSet's and display multiselect, and regular listboxes.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Populating an HTML option list from a resultset
 
Similar Threads
question about struts' html:options tag
how to display values from database in a dropdown box?
Forward only ResultSet
Urgent!!
2 Select Box`s on one page, second needs to load dynamically