JSTL fn:endsWith() function

The JSTL fn:endsWith() function is used to check whether the input string is ends with the specified string or not. It returns true if input string is ends with the specified string otherwise return false.

Syntax:

boolean endsWith(String inputString, String specifiedString)

Example:

test.jsp

<%@ 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>fn:endsWith JSTL function example</title>
	</head>
	<body>
		<c:set var="testString" 
                    value="Hello this is a JSTL function example"/>
 
		<c:if test="${fn:endsWith(testString, 'example')}">
		   <h4>String ends with example</h4>
		</c:if>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 55
 
Download this example.
 
Next Topic: JSTL fn:escapeXml() function with example.
Previous Topic: JSTL fn:startsWith() function with example.

 

Content Protection by DMCA.com
Please Share