• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dropdown Change HTML <select><option>

 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a servlet, the app context is available via servletContext.getAttribute().
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic