File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Dropdown Change HTML <select><option> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Dropdown Change HTML <select><option>" Watch "Dropdown Change HTML <select><option>" New topic
Author

Dropdown Change HTML <select><option>

Lou Pellegrini
Ranch Hand

Joined: Nov 11, 2003
Posts: 142
    
    1
Hi,

I hope this is the correct forum for this question.

My html <option> values may change frequently. Instead of reading the database every time they are needed, how can I hold them in a List to send when needed, and still be able to pick up changes without restarting the server?

Thanks,

Lou
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

Sure. Are you using a JSP to render your page?

If so store the List of options in application context where any JSP can access it, and change the List whenever you want.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lou Pellegrini
Ranch Hand

Joined: Nov 11, 2003
Posts: 142
    
    1
Thank you for your prompt reply Bear!

I still don't understand how I get a reference to the populated List object to make the changes when needed.

Thanks,

Lou
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

From a servlet, the app context is available via servletContext.getAttribute().
Lou Pellegrini
Ranch Hand

Joined: Nov 11, 2003
Posts: 142
    
    1
I think I see.

Use servletContext.getAttribute(), probably behind an admin servlet with a logon, to notify the container that it is time to reload the <option> value from the database.

servletContext.getAttribute("Mylist").reload();

Thanks Bear!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dropdown Change HTML <select><option>
 
Similar Threads
showing fields dynamically
Thread Class Method
missing end tags on html:text
HP8200 Burner - Can Anyone Burn?
no scroll bar in IE,but Scroll bar in MF