How to apply forTokens tag in JSP?

JSPJava 8Object Oriented ProgrammingProgramming

The <c:forTokens> tag has similar attributes as that of the <c:forEach> tag except for one additional attribute delims which specifies characters to use as delimiters.

AttributeDescriptionRequiredDefault
delimsCharacters to use as delimitersYesNone

Example for <c:forTokens>

<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<html>
   <head>
      <title><c:forTokens> Tag Example</title>
   </head>
   <body>
      <c:forTokens items = "Zara,nuha,roshy" delims = "," var = "name">
         <c:out value = "${name}"/><p>
      </c:forTokens>
   </body>
</html>

The above code will generate the following result −

Zara
nuha
roshy
raja
Published on 22-Mar-2019 10:12:39
Advertisements