• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to iterate through c:forEach tag

 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to find the length of the array that we iterate through in <c:forEach> tag.

Suppose we have a scenario in which I have iterate upto (n-1) element?

String[] names = {"a", "b", "c", "d"};

This can be done like (names.length-1)
for(int i=0; i<(names.length-1); i++) {
}
request.setAttribute("Names", names);

<c:forEach var="name" items=${Names} end="?" />

What should I specify for "end" attribute to achieve the same.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of JSP?
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP 2.0
JSTL 1.1
Tomcat 5.5.9
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the fn:length() JSTL function.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic