• Post Reply Bookmark Topic Watch Topic
  • New Topic

how set value as default in a select dropdownlist in a jsp page  RSS feed

 
giri shetty
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
i have a little confusion here can any one tell me ? here iam getting a state name by putting the java bean in a session and i retriving the value in a jsp and here i have setup the state value what is iam getting from that session as default in select dropdownlist in a jsp page.
thanks
giri
 
Jayson Falkner
Author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the "selected" attribute in the option element you want to be selected by default. If you are doing this dynamically, you'll have to work it in with the code that generates the HTML for the form, e.g.
<select>
<option value="foo" ${fooSelected}>Foo</option>
<option value="bat" ${barSelected}>Bar</option>
</selected>
Above is about the crudest method, but hopefully you get the idea. BTW, if you aren't using JSP 2.0, replace the &{} with the good old <%= %>.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!