Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to access c:forEach index from the tag

843836Apr 5 2004 — edited Apr 5 2005

I have a custom tag that alternates color of the row in the results tables based on the
index of the collection that I am displaying. If the row is odd it is shown as gray, if it is even it is white.
This is of course css style driven.

I am nesting it in the logic:iterate tag because this tag exposes the current index to the nested tags,
so I can easily calculate modulo 2 and detrmine if it is even or odd.

Does anyone know how to implement the same logic with JSTL 1.0 c:forEach tag.
I could not find any public or protected methods that gives me the current index. If anyone has a very concrete solution, or even a complete tag that I could re-use please let me know.

Best regards,
Edmon Begoli
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 3 2005
Added on Apr 5 2004
2 comments
477 views