aspose file tools*
The moose likes JSP and the fly likes How to iterate through c:forEach tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to iterate through c:forEach tag" Watch "How to iterate through c:forEach tag" New topic
Author

How to iterate through c:forEach tag

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
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.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

What version of JSP?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
JSP 2.0
JSTL 1.1
Tomcat 5.5.9
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

Check out the fn:length() JSTL function.
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Thanks Bear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to iterate through c:forEach tag
 
Similar Threads
iterate dynamic attribute in tag files
help in JSP
Using JSTL forEach with a custom tag
java 1.5 list iteration using jstl tag
Using EL to retrive data from Arraylist