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

Struts iterate tag and formatting

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
Hi all,

I have returned a collection of objects and am using the iterate tag to loop through them and display there names in a table.

However, intsead of displaying them like this:
onject 1
object 2
object 3
object 4

I would like to display them as this

object 1 object 2
object 3 object 4

Does anyone know of a good way of doing this?

Is there anyway you can specify if commands in the iterate tag and access the counter used by the tag?
This way I could test the following

if(counter mod 2 == 0) then insert new row

thank you

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

I suggest moving to JSTL.

Also see this:

Junilu - [How to Ask Questions] [How to Answer Questions]
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
yeah the jstl c:forEach works or you can use the index attribute in your current logic:iterate, you can do your mod test on that
I agree. Here's the link:
subject: Struts iterate tag and formatting
It's not a secret anymore!