<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">JSTL forTokens tag is used to iterate over the tokens separated by delimiters. JSTL <i><b>forTokens </b></i>tag is another tag in core JSTL library to support Iteration or looping. It effectively complements, more useful <i><b><;c:forEach>;</b></i> tag, by allowing you to iterate over comma separated or any delimited String. You can use this tag to split string in JSP and can operate on them individually. forTokens tag has similar attribute like forEach JSTL tag except one more attribute called delims, which specifies delimiter.</p>
<p> <b>JSTL <i><;c:forTokens>; </i>tag Example:</b></p>
<p> To display the names on JSP, you can use the<b><i> <;forTokens>;</i></b> tag like:</p>
<pre class="highlight" name="code"><;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>;
<;html>;
<;head>;
<;title>;<;c:forTokens>; Tag Example<;/title>;
<;/head>;
<;body>;
<;c:forTokens items="Dinesh,Anamika,Sweety" delims="," var="name">;
 <;c:out value="${name}"/>;<;p>;
<;/c:forTokens>;
<;/body>;
<;/html>;
</pre>
<p>As you can see above, in the JSTL <i><b>forTokens </b></i>tag, items attribute is used to define the tokens. It will iterate over tokens separated by delimiter. In each iteration, it will get a token defined with attribute var. status attribute keeps track of iteration.</p>
<div class="separator" style="clear: both; text-align: center;"><img border="0" src="http://50.87.249.200/~dineshon/wp-content/uploads/2013/10/1111.png" /></div>
<p>Withing starting and ending tag of ; <i><b>forTokens</b></i>, you can display or apply other logic to each token.<br />
<b><br />
Attributes of<i> <;c:forTokens>;</i> tag are:</b></p>
<p> <b>Required Attributes:</b></p>
<p>  ;<b> ; ; ; ; 1. items:</b>This attribute provides string of tokens to iterate over..</p>
<p>  ; ; ; ; ; ;<b> 2. delims:</b> This attribute provides the set of delimiters. The characters that separate the tokens in the string.</p>
<p> <b>Optional Attributes:</b></p>
<p>  ; ; ; ; ; ;<b> 1. var: </b>This attribute provides name of the exported scoped variable for the current item of the iteration. This scoped variable has nested visiblity. Its type depends on the object of the underlying collection.</p>
<p>  ; ; ; ; ; ; <b>2. varStatus: </b>This attribute provides name of the exported scoped variable for the status of the iteration. Object exported is of type <b><i>javax.servlet.jsp.jstl.core.LoopTagStatus.</i></b> This scoped variable has nested visibility.</p>
<p>  ; ; ; ; ; ; <b>3. begin:</b> If items specified: Iteration begins at the item located at the specified index. First item of the collection has index 0. If items not specified: Iteration begins with index set at the value specified.</p>
<p>  ; ; ; ; ;<b> 4. end: </b>If items specified: Iteration ends at the item located at the specified index (inclusive). If items not specified: Iteration ends when index reaches the value specified.</p>
<p>  ; ; ; ;<b> 5. step:</b> Iteration will only process every step items of the collection, starting with the first one. </div>
<p></p>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/2013/10/jstl-foreach-tag.html">Previous</a> <;<; ; ; || <a href="https://dineshonjava.com/2013/10/jsp-standard-tag-library-jstl-tutorial.html">Index </a>||  ; >;>;<a href="https://dineshonjava.com/2013/10/jstl-param-tag.html">Next</a> >;>;</b></div>
<p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/jstl-foreach-tag/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/jstl-param-tag/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '311'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…