tags:

views:

38

answers:

2

I have two arrays that I need to loop through. Using foreach, I can only loop through one at a time. A regular for(i = 0; i<7; i++) Loop would be great.

+2  A: 

Here is something from JSTL in Action:

 <c:forEach begin="1" end="5" var="current">
    <c:out value="${current}"/>
</c:forEach>
Bakkal
+1  A: 

I think I see what you mean - you have two arrays (probably of equal size), and you want to loop so that you use the loop index to access each array.

If that's what you meant (and it's far from clear from your question), then you could do something like this (assuming arrayX and arrayY).

<c:forEach items="${arrayX}" varStatus="loop">
    <c:out value="${arrayX[loop.index]}"/>
    <c:out value="${arrayY[loop.index]}"/>
</c:forEach>

This uses arrayX to get the iterator, but then uses indexed lookups into arrayX and arrayY.

varStatus is described here .

skaffman