JSTL Core forTokens Tag


JSTL Core forTokens Tag

JSTL Core forTokens Tag is use to iterate  the value which  is separated by  any delimeter . JSTL Core forTokens Tag is use to break the string on the basis of given delimeter.

forTokens is similar to split() method of String in java.

Syntax

<c:forTokens items="String_With_some_symbol" delims="delimeter" var="var_name">
 <!--Display var name here -->
</c:forTokens>

Example

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSTL Examples</title>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
</head>
<body>
 <c:forTokens items="Yogesh,Arpan,Amit" delims="," var="friends">
 <c:out value="${friends}" />
 <br>
 </c:forTokens>
</body>
</html>

Here we have delims comma

Output

Yogesh
Arpan
Amit






Full-stack web and mobile app development company Contact Us : Skype: indore.webcoder Email: info@w3sparks.com Sales: +91 8085506229