Easy Tutorial
❮ Jstl Sql Update Tag Jstl Sql Transaction Tag ❯

fn:join() Function

JSP Standard Tag Library

The fn:join() function concatenates all elements of an array into a single string using a specified delimiter.

Syntax

The syntax for the fn:join() function is as follows:

${fn:join([array], <delimiter>)}

Example Demonstration

The following example demonstrates the functionality of this function:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ 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>Using JSTL Functions</title>
</head>
<body>

&lt;c:set var="string1" value="www tutorialpro.org"/>
&lt;c:set var="string2" value="${fn:split(string1, ' ')}" />
&lt;c:set var="string3" value="${fn:join(string2, '-')}" />

<p>The string is: ${string3}</p>

</body>
</html>

Note: The fn:split function returns a string split by a specified delimiter into an array of substrings.

The output will be as follows:

The string is: www-tutorialpro.org

JSP Standard Tag Library

❮ Jstl Sql Update Tag Jstl Sql Transaction Tag ❯