Open In App

JSTL fn:endsWith() Function

In the given string, if we need to check that the string ends with the specified suffix then we can use the JSTL fn:endsWith() Function. This function mainly returns the result in Boolean form. In this article, we will discuss about the syntax, parameters, and example of the fn:endsWith() function.

Syntax of fn:endsWith() function:

${fn:endsWith(String str, String suffix)}

Where,



Example of JSTL fn:endsWith() Function

In this example, we will see how to find the length of a string using the JSTL fn:endsWith() Function.




<%@ 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:endsWith() Example</title>
</head>
<body>
<c:set var="inputString" value="GeeksforGeeks"/>
<c:set var="trueSuffix" value="Geeks"/>
<c:set var="falseSuffix" value="Java"/>
<p>Original String: ${inputString}</p>
<p>Does "${inputString}" end with "${trueSuffix}"? ${fn:endsWith(inputString, trueSuffix)}</p>
<p>Does "${inputString}" end with "${falseSuffix}"? ${fn:endsWith(inputString, falseSuffix)}</p>
  
</body>
</html>

Output:

Original String: GeeksforGeeks
Does "GeeksforGeeks" end with "Geeks"? true
Does "GeeksforGeeks" end with "Java"? false

Output Screen of the above Program:



Explanation of the above Program:


Article Tags :