File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes jstl nested inside bean:write tag ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "jstl nested inside bean:write tag ?" Watch "jstl nested inside bean:write tag ?" New topic

jstl nested inside bean:write tag ?

Ronan Dowd
Ranch Hand

Joined: Jan 21, 2006
Posts: 84
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 + "]"%>'/>

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

Joined: Feb 15, 2005
Posts: 4864
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 in your taglib definition. Once you do this, you can do the following:

Consultant, Sima Solutions
I agree. Here's the link:
subject: jstl nested inside bean:write tag ?
It's not a secret anymore!