JSTL Functions - endsWith()

The fn:endsWith() function determines whether an input string ends with a specified suffix.

Syntax:

The fn:endsWith() function has following syntax:

boolean endsWith(java.lang.String, java.lang.String)

JSTL Example :

<%@ 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 Tutorial</title>
</head>
<body>
<c:set var="str" value="Suresh Marks : 190"/>
<c:if test="${fn:endsWith(str, '190')}">
   <p>String ends with 190<p>
</c:if>
<c:if test="${fn:endsWith(str, 'Marks')}">
   <p>String ends with Marks<p>
</c:if>
</body>
</html>

Output :

String ends with 190