How to determine if an input string ends with a specified suffix in JSP?

JSPJava 8Object Oriented ProgrammingProgramming

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


The fn:endsWith() function has the following syntax −

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


Following example explains the functionality of the fn:substring function −

<%@ taglib uri = "" prefix = "c" %>
<%@ taglib uri = "" prefix = "fn" %>
      <title>Using JSTL Functions</title>
      <c:set var = "theString" value = "I am a test String 123"/>
      <c:if test = "${fn:endsWith(theString, '123')}">
         <p>String ends with 123<p>
      <c:if test = "${fn:endsWith(theString, 'TEST')}">
         <p>String ends with TEST<p>

You will receive the following result −

String ends with 123
Updated on 30-Jul-2019 22:30:25