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

logic:iterate for counter

Ronan Dowd
Ranch Hand

Joined: Jan 21, 2006
Posts: 84
Simple question, In struts am trying to print a row 5 times. in my action class i set the number of times i wish to print the row.
Correct me if I'm wrong but i dont want to use a logic:iterate as I'm not, in a sense, "iterating" over anything, I want to
basically do a good ol for loop kinda thing. Is there a nice way to do this in struts ? I want to be able to display my index variable
(count in this case) inside the property attribute of "html:text:" as in the below example..
Does anyone know if there is a cleaner way to do this than embedding java in my jsp? thanks..

for (int count=0; count<5; count++)
<td><html:text property='<%= "recordValue[" + count + "]'/></td> </tr>

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The Struts <logic:iterate> tag can't do this, but the JSTL <c:forEach> tag can. That's what I'd suggest you use. Just Google "jstl foreach" if you need the syntax.

Consultant, Sima Solutions
Ronan Dowd
Ranch Hand

Joined: Jan 21, 2006
Posts: 84
cheers for that but i can't seem to nest my JSTL count variable inside my
"<%= %>" part. I've posted a new thread (probably didnt explicity need to though) on it. any advice would be great. thanks - Ronan.
I agree. Here's the link:
subject: logic:iterate for counter
It's not a secret anymore!