• Post Reply Bookmark Topic Watch Topic
  • New Topic

Drop down menu values from database.

 
gurneeraj singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making a page which is used for order processing and updates databse with order values.

This page contains many drop down menus which get values from a database like product id, product name, product description, city and state.

But i don't want client to face overhead each time of accessing database to get these drop down menu values. What can be the bast solution for this?

My understanding is to use servletcontext object to store these values on server startup using servletcontextlistener and then fill these values to drop down menu. But this has a issue what if client wish to update these values like new product addition then after each updation server has to be restarted to get these updated values.

So, i am left with accessing database directly but i wish to use best technique for it.

What i have in my mind are:-
1) Access database directly from jsp page using <sql: tags.
2) use these values through a javabean
3) Or control the whole process through a servlet but for just filling values of drop down menu from databse i don't think this method is good or even its possible.
4) Make a custom tag with table attribute so that i get values from that concerned database table only like for city, state, product, etc

Kindly tell me with best technique for this issue.

Thanks in advance.>
 
Ankit Garg
Sheriff
Posts: 9591
34
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gurneeraj singh wrote:My understanding is to use servletcontext object to store these values on server startup using servletcontextlistener and then fill these values to drop down menu. But this has a issue what if client wish to update these values like new product addition then after each updation server has to be restarted to get these updated values.


Well this looks like a good solution to me. You can create a ServletContextListener and get the values from the database and store then in ServletContext. And if you wants to add more values, then you can create a servlet which will receive values for the new field (i.e. create a page that allows admin to add new values to the columns which will send the new column details to this servlet), add then to the database and update the values in the ServletContext. That way you won't have to restart the server...
 
gurneeraj singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great Solution! yes i will do the same.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!