struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Evans <>
Subject Re: iterating over multiple Collections in one loop with JSTL
Date Thu, 25 May 2006 16:11:58 GMT
<c:forEach items="list1" var="list1Item" varStatus="status">

the status variable is an instance of LoopTagStatus, which has an index
property that is set by the forEach loop.

I might favor combining the two lists (in your action) into a single
list, each element of which has a list that holds the two items from the
lists. so you'd access it like:

<c:forEach items="bothListsList" var="listItems" >


On Thu, 2006-05-25 at 08:28 -0700, Pat Slater wrote:
> Hi,
> Is it possible to do with JSTL something like this: 
> (Note: size of list1 and list2 are equal)
> List list1 = getList1();
> List list2 = getList2();
> for(int i=0; i<list1.size(); i++)
> {
>     MyClass1 x1 = (MyClass1)list1.get( i );
>     MyClass2 x2 = (MyClass2)list2.get( i );
> }
> ----------------------------------------------------------------------------
> I can iterate with JSTL with forEach for either of the lists separately but I need to
display both of them in the same loop. How can I do that?
> ---------------------------------
> Sneak preview the  all-new It's not radically different. Just radically better.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message