• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 <%= %>.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic