JSTL fn:replace() Function Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The JSTL fn:replace() function or method in JSP (Java Server Pages) is mainly used for the manipulation of strings. This function allows developers to replace the occurrence of a specified substring with another substring in the given input string. This article will see the Syntax, parameters, and two practical examples of the fn:replace() function. We need to note that the replace function performs case-sensitive processing of string. Syntax of fn:replace()${fn:replace(sourceString, targetSubstring, replacementSubstring)}Where, sourceString: This is the input or original string in which the replacement or modification is to be done.targetSubstring: This is the substring to be replaced in the sourceString.replacementSubstring: This is the substring that will mainly replace occurrences in the targetSubstring in the sourceString. Example of fn:replace() functionBelow is the implementation of the fn:replace() function: HTML <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="http://www.oracle.com/technetwork/java/index.html" prefix="c" %> <%@ taglib uri="http://www.oracle.com/technetwork/java/index.html" prefix="fn" %> <html> <head> <title>JSTL fn:replace() Example</title> </head> <body> <c:set var="originalString" value="GeeksforGeeks is a platform for computer science students. GeeksforGeeks is good." /> <p>Original String: ${originalString}</p> <c:set var="modifiedString" value="${fn:replace(originalString, 'GeeksforGeeks', 'GFG')}"/> <p>Modified String: ${modifiedString}</p> </body> </html> Output:Original String: GeeksforGeeks is a platform for computer science students. GeeksforGeeks is good.Modified String: GFG is a platform for computer science students. GFG is good.Final Output Shown in the Browser: Explanation of the above Program: In the above example, we have initialised the "originalString" variable with the text. Then, we used the "fn:replace()" function to replace the occurrences of "GeeksforGeeks" with the "GFG" in the originalString variable.The replaced string is been saved in the "modifiedString" variable and we are printing it on screen using <p> tag in HTML. Comment More infoAdvertise with us Next Article JSTL fn:length() Function G gauravggeeksforgeeks Follow Improve Article Tags : Advance Java Java-Spring-Boot Geeks Premier League 2023 Similar Reads 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 JSTL fn:length() Function In JSTL, the fn:length() function is mainly used to specify the length or size of a collection, array, or string in JSP. This function returns the number of elements in the given object as input. Used to retrieve the size or length information within the JSTL expressions. The fn:length() function is 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:toLowerCase() Function In JSTL, the fn:toLowerCase function converts all the characters of the input or specified string into the lowercase format. This allows the developers to transform the string case with the JavaServer Pages and also ensures the proper representation of text in lowercase. In this article, we will see 2 min read JSTL fn:toUpperCase() Function In JSTL, the fn:toUpperCase() function is used to transform all the characters in a specified string to uppercase. If the input string is in lowercase, then this function can convert all the characters into uppercase. In this article, we will see the Syntax along with Parameters and detailed impleme 1 min read 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 Like