Easy Tutorial
❮ Jstl Core Set Tag Jstl Sql Update Tag ❯

fn:endsWith() Function

JSP Standard Tag Library

The fn:endsWith() function is used to determine if a string ends with a specified suffix.

Syntax

The syntax for the fn:endsWith() function is as follows:

<c:if test="${fn:endsWith(<original string>, <substring to find>)}">
...
</c:if>

Example Demonstration

The following example demonstrates the functionality of this function:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ 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>Using JSTL Functions</title>
</head>
<body>

&lt;c:set var="theString" value="I am from tutorialpro 123"/>

&lt;c:if test="${fn:endsWith(theString, '123')}">
   <p>String ends with 123<p>
</c:if>

&lt;c:if test="${fn:endsWith(theString, 'unoob')}">
   <p>String ends with tutorialpro<p>
</c:if>

</body>
</html>

The output is as follows:

String ends with 123

JSP Standard Tag Library

❮ Jstl Core Set Tag Jstl Sql Update Tag ❯