This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Author

JSTL sql taglib and html drop down box

namrata suri
Ranch Hand

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

Joined: Jul 15, 2009
Posts: 377

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


I love this place!
Ben Souther
Sheriff

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.

-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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
Consider Paul's rocket mass heater.
 
subject: JSTL sql taglib and html drop down box
 
Similar Threads
Changing options(contents) of a select element in Struts' jsp form
unable to do validation for select in struts2
Getting drop down value in JSP as request scope.
javascript error in populating select box
can anyone tell me how do we update the values in servlet?