Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JSTL sql taglib and html drop down box

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a form from which the values are being passed to another jsp. In this jsp, i have a drop down box with some options. based on the value submitted by the form, one of those options has to be selected automatically or made the default value.

I am not using html struts taglib.

so my code is like this



That is the rough structure. Since, s was passed, I need to make s the default selection in the drop down box.
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

The simple solution is to use a framework (spring/struts) as I [think] they all come with this functionality.
Another option is either to litter your JSP code with core taglib choose/when/otherwise tags.
Finally, another option is to create your own taglib with tags for creating <option> tags and will go selected if values are equal.

Sean
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't recommend heavyweight framework for a small feature like this.

Read up on JSTL's forEach tag.
You can use it to iterate over your data to produce the option tags.

-Ben


PS: I wouldn't use JSTL's SQL tags either.
The spec for them states that they are for quick prototyping and trivial applications, not for production code.
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic