Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL sql taglib and html drop down box

 
namrata suri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • 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.
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic