• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP 2.0 EL and html:options issue

 
Sri Ram
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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>
</c:forEach>
</html:select>


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
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use custom tags in the attribute values of other custom tags.
[ December 28, 2005: Message edited by: Bear Bibeault ]
 
Stefan Evans
Bartender
Posts: 1691
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
</c:forEach>

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic