File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes JSTL sql taglib and html drop down box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL sql taglib and html drop down box" Watch "JSTL sql taglib and html drop down box" New topic

JSTL sql taglib and html drop down box

namrata suri
Ranch Hand

Joined: Oct 22, 2009
Posts: 31
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

Joined: Jul 15, 2009
Posts: 377


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.


I love this place!
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

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.


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.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: JSTL sql taglib and html drop down box
jQuery in Action, 3rd edition