Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jstl nested inside bean:write tag ?

 
Ronan Dowd
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to render an input box "n" times (the value of n will be a request attribute). I tried using JSTL forEach as below:

<c:forEach var="count" begin="0" end="${request.numberOfTimes}">
<html:text property='<%= "fieldValue[" + count + "]"%>'/>
</c:forEach>

This doesnt seem to work. I know that i can get the value of the current count by doing <c ut value="${count}"> but I can't nest this JSTL fragment
inside my "<%= .... %>" tags! Essentially i want count to be printed for each iteration of the loop.
Can someone provide me with a code sample if poss of how to get around this? is there a way i can
- either nest my JSTL inside my "<%= .. %>"
- or using some other struts way, render my count value

Thanks. Ronan.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd suggest using the EL version of the Struts tags. They allow you to embed EL expressions in your tags. Just make sure that the struts-el-1.3.x.jar is in your WEB-INF/lib directory and reference the URI http://struts.apache.org/tags-html-el in your taglib definition. Once you do this, you can do the following:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic