JSTL for Loop

Consider a case where we want to do something with a collection like an array, retrieving one element at a time, and prints that element in a dynamically generated row.

JSTL for Loop <c: forEach>

Consider a case where we want to do something with a
collection like an array, retrieving one element at a time, and prints that
element in a dynamically generated row. For this <c: forEach>
tag is perfect, this tag gives you the options to iterate over arrays
and collections.

In the tag <c:forEach var="i" begin="1" end="20" step="1" varStatus ="status">.
Here this tag is working exactly as, for loop works in a jsp or in java. In this
example i is the
name of the variable, which begins from 1 and continues up to 20, we are incrementing
the variable by 1, to increment the variable we have used step attribute. To print the value
of the variable on the browser use <c:out>
tag.

Stephanie
April 18, 2011
jstl foreach loop
I am a student working on a jsp project and am having trouble getting values from a java class to at jsp page using a jstl forEach loop. This is the loop:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:forEach items="${Products}" var="product" >
<tr>
<td>${product.code}</td>
<td>${product.description}</td>
<td>${product.price}</td>
</tr>
</c:forEach>
And this is the array it is calling from a java class called ProductsServelet
HttpSession session = request.getSession();
ArrayList<Product> products =
ProductIO.getProducts(
session.getServletContext().getRealPath("WEB-INF/products.txt"));
session.setAttribute("products", products);
Can anybody help?

Kyaw Myint Thu
April 18, 2011
JSTL
trying

Michael
June 24, 2011
<c:forEach> Question
What is varStatus ?

basit
March 15, 2012
JSTL for each loop
to know about JSL for each loop but plz use ArrayList of object type of class

Mitesh
September 18, 2012
question
I copy pasted the same code but when I open the url from a browser i get the following output:
${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i} ${i}
I was expecting numbers -
any idea what could be wrong? I am deploying this on Websphere app server