This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes drop down values in jsp 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 » EJB and other Java EE Technologies
Bookmark "drop down values in jsp" Watch "drop down values in jsp" New topic
Author

drop down values in jsp

Rajah Nagur
Ranch Hand

Joined: Nov 06, 2002
Posts: 239
hello all,
what is the best way to retreive the drop down data from the database to display in a jsp in a 3 tier env? what abt the dependent drop downs.?


You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

You really can't do anything fundamentally different with JSP from what you can do with HTML. You still make your drop down box with HTML form elements, but instead of hard-coding the values, you can pull them from a database or something. You can use Java Script to populate dependant drop downs dynamically.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
If you're using an MVC style architecture then you could retrieve the contents of the lists from the database, and place it request scope ready to be rendered by the JSP view. This rendering could be implemented using a view helper such as a custom tag.
Check out Chapter 8 of my book (in PDF format) that has an example custom tag to help render drop downs. Say that you have a collection of JavaBeans in that collection representing countries, the tag takes the name of the bean properties that will be used for the key and display values (e.g. country ID and name), and uses Java's reflection mechanism to access them.
Hope it's useful...
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: drop down values in jsp
 
Similar Threads
Drop down calendar
populate a drop-down listbox
trying to submit form on another site from my JSP
Drop down menu look
need help in jsp