Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retain the selected values of a dropdown in the result page using JSP and servlet

 
Aparna Sudhakaran
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having a JSP page with 2 dropdown lists and a google map. on selecting values from the drop down list, a call is made to a servlet which makes the DB connection and retreives values from the DB and then pushes the result into another JSP which has the resultant map. i want that the drop downs from the first JSP be visible in this 2nd resultant JSP along with the selected values.
Please help.
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One option would be to create a java class to represent each item in your drop-down list, and then use an ArrayList (or something similar) of these objects stored in the user's session. Decide for yourself if it's easier to create a "selected" boolean field your item's class (perhaps good for a multiselect), or to simply store the index of the selected item in another session variable (easiest when only selecting one value).

You would be responsible for keeping the list in the user's session in sync with the page on their screen, but that shouldn't be too tricky for what you are asking to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic