Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prepopulating a jsp

 
santu Naid
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp page which has many fields like text, textarea, drop down, radio button,
First the user enters all the values into this page and goes to some other page, and in this way he continues,but there is a link in on of the pages which brings him back to the first page. when he comes to this page all the filds should be prepopulated.

I made a session, in which i saved all the entered data, and when i come to the first page i am able to get the entered data.And i am able to prepopulate the text fields using value=<%=entereddata%>, but how can i prepopulate a drop down, i mean have a drop down in a selected state
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By adding selected or 'selected="selected" to an option, you can let the browser know that a particular entry has been selected.

 
santu Naid
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The options to be selected is not constant, it changes every now and then,

When a user selects an option, and then leaves the page to go to a new page,
and when he returns to same page again, the drop down should be in a selected state, the same option which he selected before.

while run time...
When i come to this page i have the value of the selected option from the session object , with this value how can i make the drop down to be in selected state with that value dynamically.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Typically it would look something like this:



There are less verbose ways of doing this but I think this is the most explanatory.
[ January 07, 2008: Message edited by: Gregg Bolinger ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic