BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

fn:endsWith() – JSTL Function

Last Updated: December 1, 2013 by Chaitanya Singh | Filed Under: JSTL

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:

fn-endsWith-example

 

Top Related Articles:

  1. fn:join() and fn:split() JSTL Functions
  2. fn:substring(), fn:substringAfter() & fn:substringBefore() Functions
  3. fn:toUpperCase() – JSTL Function
  4. JSTL <c:out> Core Tag
  5. JSTL <c:url> Core Tag

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

JSTL Core Tags

  • c:out
  • c:set
  • c:remove
  • c:if
  • c:choose
  • c:when
  • c:otherwise
  • c:catch
  • c:import
  • c:forEach
  • c:forTokens
  • c:param
  • c:url
  • c:redirect
JSTL Functions
  • fn:contains()
  • fn:containsIgnoreCase()
  • fn:indexOf()
  • fn:escapeXML()
  • fn:join() & fn:split()
  • fn:length()
  • fn:startsWith()
  • fn:endsWith()
  • fn:substring()
  • fn:substringAfter()
  • fn:substringBefore()
  • fn:trim()
  • fn:toUpperCase()
  • fn:toLowerCase()
  • fn:replace()

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap