Java Tutorial/JSTL/ForTokens
JSTL ForTokens
<source lang="java">
<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %> <html>
<head> <title>Updatable Collections</title> </head> <body>
Parse for Tokens |
Enter a sentence:
|
<input type="submit" name="parse" value="Parse" /> |
<c:if test="${pageContext.request.method=="POST"}">
Word <c:out value="${i}" /> |
<c:out value="${word}" /> |
</c:if> </body>
</html></source>
Use JSTL ForTokens to split string
<source lang="java">
<%@ taglib prefix="c" uri="http://java.sun.ru/jstl/core" %> <c:set var="names" value="A:B;C|D" scope="page" /> <html>
<head> <title>forTokens action</title> </head> <body> <c:forTokens items="${pageScope.names}" delims=":;|" var="currentName" varStatus="status" > Family member #<c:out value="${status.count}" /> is <c:out value="${currentName}" />
</c:forTokens> </body>
</html></source>