JSTL fn:split() Function

In this tutorial you will learn about the JSTL fn split function.

JSTL split Function returns the array of String after splitting the target string with specified separator.

Sometimes it is required to split the string into a various part. For this JSTL function Library provides a function named split() that splits the string using a delimiter. This function splits a string into an array of string.

The fn:split() function has following syntax:
java.lang.String[] split(java.lang.String, java.lang.String)

JST Split Function Example-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSTL Split Function Example</title>
  <c:set var="array1" value="${fn:split('Hi My name is Dinesh', ' ')}">

Output: [Hi,My,name,is,Dinesh]

As you can see above, fn:split() takes a String as input parametes and returns the array of String after splitting it based on separator specified in 2nd parameter.

<<Previous <<   || Index ||   >>Next >>