File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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.
I agree. Here's the link:
subject: JSTL forEach syntax
It's not a secret anymore!