FreeKB - Java Programming JSTL Loop through an array using c:forToken
Java Programming - JSTL Loop through an array using c:forToken

This assumes you are already familiar with creating variables using c:set and printing variables using c:out. Let's take an example of an array called names that contains a few names Jeremy.

<c:set var="family">Jeremy, Natalie, Winston, Riker</c:set>

 

c:forToken is used to loop through the array.

<c:forTokens items="${family}" delims="," var="members">
    ${members}<br />
</c:forTokens>

 

Running this application should print each family member.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 94c4d in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |