jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Retain a selected value in a drop down. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Retain a selected value in a drop down." Watch "Retain a selected value in a drop down." New topic

Retain a selected value in a drop down.

Ash Acharya

Joined: Jan 09, 2009
Posts: 11
I have a jsp wherein I have a select box, which gets populated from the database on form load. How do I get the selected value in the drop down when i visit the same page again?what I exactly mean is that i want to retain the previously selected value in the select box the next time i revisit the same page. I'm able to populate the other text fields on the form with the values they originally had, when i revisit the page. How can I achieve this?

Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

You need to make sure that the name attribute in select tag matches the getter for the selected value.
If that is not possible for some reason, you should be able to set the selected option by setting it explicitly in the value attribute.

The future is here. It's just not evenly distributed yet. - William Gibson
Sonny Gill LinkedIn
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Retain a selected value in a drop down.
It's not a secret anymore!