forTokens in JSP Core Tag Library

What is "forTokens" tag in JSP Core Tag Library?


The forTokens tags is used to iterate the strings tokenized by the delimiters specified by the "delims" attribute. In each iteration the current token will be stored with the "var" attribute.


<c:forTokens var="name" items="expression" delims="expression"
begin="expression" end="expression" step="expression">

In the above example the values given in the "items" attribute seperated by the delimiter given in the "delims" attribute are tokenized and iterated based on the values of "begin", "end", "step" attributes.

Example :

<%@ taglib uri="" prefix="c" %>
<p>Example for forToken in Core Tag Library.</p>
<c:forTokens var="token" items="apple#banana&capsicum,eggfruit"
<c:out value="${token}"/>
Result :

Example for forToken in Core Tag Library.
apple#banana capsicum eggfruit

In the above example we have used the delimiters ",", "&" to tokenize the string.

Ask Questions

Ask Question