fn:join() JSTL Function
fn:join() JSTL Function Example explains about How to Join all elements of an array into a string.
Consider an example string where you need to convert all the elements of an array into string.
fn:join() JSTL Functiion will used to combine / merge every elements of a particular array into a string.
java.lang.String join(java.lang.String[], java.lang.String)
You can see the below example, which is demonstrating fn:join() JSTL Function
Required Libraries
fn:join() Example
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> <html> <head> <title>JSTL fn:join</title> </head> <body> <% // you can also set the values into request scope same as using c:set // request.setAttribute("str", "Testing a String"); %> <c:set var="str" value="Testing a String" /> <c:set var="array" value="${fn:split(str, ' ')}" /> <c:out value="${fn:join(array,'|')}" /> </body> </html>
Output
Testing|a|String
2 Responses to "fn:join() JSTL Function"