fn:join tag of Function Tag Library

What is "fn:join" tag of Function Tag Library?


"fn:join" is a string function of JSP Standard Tag Library(JSTL). This function is used to return string with all the elements of an array seperated by a "seperator".



In the above syntax the "array" is an array, "seperator" is of data type "String".

Example :

<%@ taglib uri="http://java.sun.com/jsp/jstl/core"
prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"
prefix="fn" %>
<c:set var="str" value="j o i n"/>
<p><b>The string array "join" using "|"::</b></p>
<c:set var="jnd" value="${fn:split(str,' ')}" />
<c:out value="${fn:join(jnd,'|')}" />
Result :

The string array "join" using "|"::

In the above example we have used the string "j o i n". All the elements of the string is split and stored in an array "jnd" like {"j" "o" "i" "n"}. This array is displayed as string seperated by "|".

Ask Questions

Ask Question