aspose file tools*
The moose likes Servlets and the fly likes dynamically populate drop-down box? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "dynamically populate drop-down box?" Watch "dynamically populate drop-down box?" New topic
Author

dynamically populate drop-down box?

Annette L'Heureux
Ranch Hand

Joined: Dec 07, 2000
Posts: 135
I may be way off here, but is there a way to dynamically populate, using jsp, a drop-down box (a regular html form object)? I would need to access an oracle database, and pull up all the records in 1 column which would make up my drop-down list. I would need to dynamically do this, in case new records are ever added. Please tell me I'm not dreaming!!
thanks,
Annette
Kevin Adams
Greenhorn

Joined: Nov 12, 2000
Posts: 21
Here's what we do: I hope this answers your question.
Once you get a connection to the file you need, simply loop through the file and write out the options to the web page...

Kevin
Annette L'Heureux
Ranch Hand

Joined: Dec 07, 2000
Posts: 135
Thanks Kevin, I definetly understand the idea! Now I'll just play around with it and see if I can get it to work. Do you put your code in a seperate servlet?
Thanks again!
Annette
Annette L'Heureux
Ranch Hand

Joined: Dec 07, 2000
Posts: 135
How do I get that code to run when a page is loaded?
The basic idea for me is that I will have some kind of link on the left, and it will load the new page on the right, but I need the drop-down box to be populated right away. So is there a way to get code to run on startup or something similar?
Darryl McCool
Greenhorn

Joined: Jan 03, 2001
Posts: 8
The code in the JSP will be run as soon as you hit the JSP with your browser. So when the browser is ready to render the HTML in the JSP to the screen, the database has already been accessed and the <OPTION> tags have already been created from the data. The page is rendered with the drop-down box populated with this data.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Annette,
It is always good idea to minimize Java code in .jsp file. Especially dealing with DBConnection,database etc. Put those logic in a Java bean and keep it separate.
Please take a look at Frank's sample code in this discussion. You may get some idea.
http://www.javaranch.com/ubb/Forum7/HTML/001041.html
regds
maha anna
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Sudhir Pawar,
Your post was moved to a new topic.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamically populate drop-down box?