fn:endsWith() function is used for checking the suffix of a string. It checks whether the given string ends with a particular string. The validation is case sensitive.
Syntax
boolean fn:endsWith(input_string, suffix_string)
It validates whether the input_string ends with suffix_string. If the test is successful then the function returns true else it gives false. The return type of the function is boolean and it receives both the strings as arguments.
Note: It considers the case while doing the check.
Example of fn:endsWith()
In the example we have a input string “BeginnersBook.com” and 4 other strings. We are verifying whether the input string ends with given four strings.
<%@ 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> String ends with ".com": ${fn:endsWith("BeginnersBook.com", "com")} <br>String ends with "book.com": ${fn:endsWith("BeginnersBook.com", "book.com")} <br>String ends with "Book.com": ${fn:endsWith("BeginnersBook.com", "Book.com")} <br>String ends with "Book.co": ${fn:endsWith("BeginnersBook.com", "Book.co")} </body> </html>
Output: