JSTL fn:substring() Function Last Updated : 14 Dec, 2023 Comments Improve Suggest changes Like Article Like Report In JSTL, the fn:substring() function is used to extract or retrieve the part of a given input or specified string, by starting from the start index to the end index [optional]. This function is mainly used for string manipulation tasks by many developers. In this article we will explore the Syntax along with the Parameters of the JSTL fn:substring() function, also we will see the practical implementation of this function in terms of examples. Syntax of JSTL fn:substring() Function${fn:substring(string, startIndex ,endIndex)}Where, string: input string from which the part of the substring will be extracted.startIndex: initial position or the starting index (inclusive) for the substring. This means that the extracting will start from this index.endIndex: ending index (exclusive) which is optional for the substring.Note: If this index is not included, then the substring continues to the end of the input string Example of fn:substring()In this example, we will discuss the use of fn:substring(), to generate different substrings. HTML <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ 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:substring() Example</title> </head> <body> <c:set var="mainString" value="GeeksforGeeks"/> <h3>Main String: ${mainString}</h3> <p>Substring from index 5 to the end: ${fn:substring(mainString, 5)}</p> <p>Substring from index 0 to 5: ${fn:substring(mainString, 0, 5)}</p> </body> </html> Output:OutputExplanation of the above Program:mainString is initialized with the value "GeeksforGeeks".The first <p> tag mainly extracts the substring from index 5 to the end of the main string, result string is forGeeks.In the second <p> we are extracting a substring from the index 0 to 5 (excluding index 5) of the main string, the result printed is Geeks. Comment More infoAdvertise with us Next Article JSTL fn:substring() Function G gauravggeeksforgeeks Follow Improve Article Tags : Java Geeks Premier League Java JSTL Geeks Premier League 2023 JSTL +1 More Practice Tags : Java Similar Reads JSTL fn:substringAfter() Function In the main string, if we want to return the subset of the string followed by a specific substring then we can use the JSTL fn:substringAfter() Function. JSTL substringAfter() FunctionThis function mainly returns the portion of the string that comes after the given string value. In this article, we 2 min read JSTL fn:substringBefore() Function In JSTL, the fn:substringBefore() function is mainly used to return the subset of the string before a specific substring. This function extracts the substring before a specified delimiter in the given input string. In this article, we will discuss about the syntax, parameters, and example of the fn: 2 min read JSTL fn:trim() Function In JSTL the fn:trim() function is used to remove the leading and trailing whitespaces in the given input or specified string. The fn:trim() function also helps in properly cleaning up and standardizing the formatting of strings within the JSP. In this article, we will see the detailed syntax and the 2 min read JSTL fn:startsWith() Function In JSTL the fn:startsWith() function is used to check if a given string starts with a particular prefix. This function returns the boolean value as True or False according to the check result. If the input string begins with the prefix then true is been returned else false is been returned. In this 2 min read JSTL fn:split() Function The JSTL fn:split() function is used to split the input string into an array of different substrings based on the delimiter. This function is helpful to the parsing of strings within the JavaServer Pages, which also allows the developers to extract the substring from the main string. In this article 2 min read Like