This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JSP and the fly likes JSTL forEach syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL forEach syntax" Watch "JSTL forEach syntax" New topic

JSTL forEach syntax

ajithsasi kumar

Joined: Apr 06, 2008
Posts: 21
In the forEach syntax what does varstatus means
Balasubramani Dharmalingam
Ranch Hand

Joined: Dec 06, 2004
Posts: 116
"varstatus" attribute in forEach will give you an index of the element in iterating List.

For first iteration its value will be 1
For second iteration its value will be 2..

Balasubramani SD,<br />SCJP 1.4,SCWCD 1.4,SCJP 5.0<br /><a href="" target="_blank" rel="nofollow"></a>
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

It's a bit more than that. varStatus gives you access to a scoped variable whose type is javax.servlet.jsp.jstl.core.LoopTagStatus.
If you look at this class API, you'll see that it allows you to get more information about the loop.

[My Blog]
All roads lead to JavaRanch
Anirvan Majumdar
Ranch Hand

Joined: Feb 22, 2005
Posts: 261
I'd also recommend this site for clearing up any doubts you might have about the for-each tag. All attributes of this tag are quite clearly explained.
It is sorta covered in the JavaRanch Style Guide.
subject: JSTL forEach syntax