File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Populating a drop down list from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Populating a drop down list from database" Watch "Populating a drop down list from database" New topic

Populating a drop down list from database

Zeko Mbumwae

Joined: Aug 08, 2009
Posts: 12
I would like to get all data(say Identity Numbers from table Emp) from the database into a <select> component (drop down list) for the user to select the right ID NUM and then further input this ID NUM and other form attributes into another table.

How do I get this done in JSP - populating the drop down list?


Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
If you are getting data from the database in the servlet then store those data in to the ArrayList and forward the request to jsp by setting the ArrayList in any of the scope like request or session scope then display them in the jsp.


Failure is not an option.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

If the option values and display text are to be different, a LinkedHashMap is a great way to send the dropdown data to the JSP.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Populating a drop down list from database
jQuery in Action, 3rd edition