CodesJava

Easy learning with example program codes

JSTL c:forTokens Core Tag


The JSTL <c:forTokens> Core Tag is used for the iteration process. It breaks the string into tokens by using delimiter and then iterate through tokens.

Syntax:

<c:forTokens items="string" delims="delimiter" var="varName">
          //block of statemtnts
</c:forTokens>

c:forTokens tag attributes:

Attribute Description Required
items Information to loop over. No
begin Element to start with (0 = first item, 1 = second item, …). No
end Element to end with (0 = first item, 1 = second item, …). No
step Process every step items. No
var Name of the variable to expose the current item. No
varStatus Name of the variable to expose the loop status. No

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<html>
	<head>
		<title>c:forTokens JSTL core tag example</title>
	</head>
	<body>
	 <h4>Tokens passed in the String "sunil, bharat, richi" are:</h4>
         <br/>
	 <c:forTokens items="sunil, bharat, richi" delims="," var="name">
   		<c:out value="${name}"/><p>
	 </c:forTokens>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 39
 
Download this example.
 
Next Topic: JSTL c:url Core Tag with example.
Previous Topic: JSTL c:forEach Core Tag with example.

Related Topics:

JSTL c:out Core Tag with example.
JSTL c:set Core Tag with example.
JSTL c:remove Core Tag with example.
JSTL c:catch Core Tag with example.
JSTL c:if Core Tag with example.
JSTL c:choose , c:when and c:otherwise Core Tags with example.
JSTL c:import Core Tag with example.
JSTL c:forEach Core Tag with example.
JSTL c:forTokens Core Tag with example.
JSTL c:url Core Tag with example.
JSTL c:param Core Tag with example.
JSTL c:redirect Core Tag with example.

 

Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki