JSTL - Loop through an array using c:forToken

Home > Search
  by

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 in the box below so that we can be sure you are a human.




Comments