Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Decalring a int variable and using it in for loop in JSTL or EL

 
Murali Charan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would like to declare a int variable and use it as the looping variable.

Just like this

for(int i=0; i<10; i++)
{
// do something
}

I want to do this in a JSP.

I can do it in scriplet. But I dont want to use a scriplet and want the do it using either a JSTL (<c:forEach>) or EL.

I am able to iterate through a List using <c:forEach> will I able able to do this using <c:forEach> or anyother JSTL tags.

Please let me know.

Thanks,
Murali
 
Prasad Tamirisa
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<c:forEach> Tag should definitely have an items attribute. So, this can not be used exactly as normal for loop.

This can be used effectively in a situation like "If you want to display list of people or list of strings in a jsp......you can iterate it using this tag."
[ May 28, 2008: Message edited by: Prasad Tamirisa ]
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible.

Ex:

 
Prasad Tamirisa
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marimuthu Madasamy:
It is possible.

Ex:



I never know this....Thanks Madasamy.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is also a varStatus attribute which has index and count properties.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic