JSTL Functions – endsWith()

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


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" %>

<title>JSTL Tutorial</title>

<c:set var="str" value="Suresh Marks : 190"/>

<c:if test="${fn:endsWith(str, '190')}">
   <p>String ends with 190<p>

<c:if test="${fn:endsWith(str, 'Marks')}">
   <p>String ends with Marks<p>


Output :

String ends with 190