File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes JSP 2.0  EL  and html:options issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP 2.0  EL  and html:options issue" Watch "JSP 2.0  EL  and html:options issue" New topic

JSP 2.0 EL and html:options issue

Sri Ram
Ranch Hand

Joined: Sep 08, 2002
Posts: 48

It might be simple but I couldn't figure it out ..

I have a jsp in which I have the following code

<html:select property="svenv">
<html ption value="0">(any)</html ption>
<c:forEach var='se' items='${sessionScope.UserInfo.svenv}'>
<html ption value="<c ut value='${se}'/>"><c ut value='${se}'/></html ption>

if I invoke the jsp and see the source code

select name="svenv"><option value="0">(any)</option>

<option value="<c ut value='${se}'/>">Save</option>

<option value="<c ut value='${se}'/>">Print</option></select>

Is there anything wrong in giving

<html ption value="<c ut value='${se}'/>"> ?

My problem is value attribute does not have Save or Print . I don't know what I am missing ..please shed some light
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

You can't use custom tags in the attribute values of other custom tags.
[ December 28, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
If you have a JSP2.0 container, you can use EL expressions in the htmlption tag
<c:forEach var='se' items='${sessionScope.UserInfo.svenv}'>
<htmlption value="${se}"><cut value='${se}'/></htmlption>

Alternatively use the htmlptions tag rather than the c:forEach tag, but I'm not sure if you can use it with a collection of strings.
I think it would be something like this,
<htmlptions name="UserInfo" property="svenv"/>

That is starting to branch off into struts territory though.
I agree. Here's the link:
subject: JSP 2.0 EL and html:options issue
It's not a secret anymore!