fn:substring(), fn:substringAfter() & fn:substringBefore() Functions

In this tutorial we will discuss fn:substring (), fn:substringAfter() and fn:substringBefore() functions of JSTL. All of these functions are used for getting a part of the string from a given input string. The way of getting the output is different in all three functions.

fn:substring ()

This function returns a substring of given input string as per the given start and end position.

Syntax

String fn:substring(String inputstring, int start, int end)

Return type of function: String

inputstring: The string from which a substring needs to be taken

start: Starting position of substring

end: end position of substring

Example – fn:substring() function

In this example we are fetching a substring from a given string by providing the starting and end positions of the substring.