Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Obtaining total items for c:forEach  RSS feed

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wondering is there a way to obtain the total items in "access"?



JSTL 1.0
JSP 1.2
Container Oracle 10.1.2

Thank you for your time
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "total items" I am assuming you mean the count of items.

In JSP 1.2/JSTL 1.0 there is no standard way to do this. In JSTL 1.1 (which requiers JSP 2.0), there is a length function.

You can either pass the count to the JSP as a separate scoped variable or write a little custom tag to set one up from the collection.

You will reap a lot of benefits to upgrading to JSP 2.0 if that's possible for you.
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use the ${status.last} and ${status.count} attributes as a hack to get around it. You're iterating through the entire list anyway. It will add a little overhead with the c:if on every iteration, but that would be negligible.



Cheers,
evnafets
[ August 06, 2006: Message edited by: Stefan Evans ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!