Reputation: 504
I have code like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSTL forEach varStatus index Example</title>
</head>
<body>
<c:forEach items="${productList}" var="product" varStatus="status">
<c:out value="${status.index+1}"/>.<c:out value="${product.name}" escapeXml="false" />
</c:forEach>
</body>
</html>
which gives me the index and product.name from each iteration. For example,
1 product1
2 product2
3 product3
Now I cant find the answer anywhere is it possible to get the product.name from the NEXT iteration like i did with the index
adding +1 to it. Could anyone please answer that question for me? Thanks.
Upvotes: 2
Views: 5701