How to retain the selected values of a dropdown in the result page using JSP and servlet
posted 4 years ago
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.
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.
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower