my dog learned polymorphism*
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: 60822
    
  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 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: 60822
    
  65

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!
 
 
subject: Dropdown Change HTML <select><option>
 
Similar Threads
no scroll bar in IE,but Scroll bar in MF
showing fields dynamically
Thread Class Method
HP8200 Burner - Can Anyone Burn?
missing end tags on html:text