aspose file tools*
The moose likes JSP and the fly likes How to retain the selected values of a dropdown in the result page using JSP and servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to retain the selected values of a dropdown in the result page using JSP and servlet" Watch "How to retain the selected values of a dropdown in the result page using JSP and servlet" New topic
Author

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

Aparna Sudhakaran
Greenhorn

Joined: Nov 23, 2011
Posts: 6
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

Joined: Aug 30, 2010
Posts: 147

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.


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retain the selected values of a dropdown in the result page using JSP and servlet