aspose 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
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 Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    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: 61226
    
  66

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 Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    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: 61226
    
  66

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

Joined: Nov 11, 2003
Posts: 150
    
    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!
 
wood burning stoves
 
subject: Dropdown Change HTML <select><option>