fn:containsIgnoreCase() JSTL Function

fn:containsIgnoreCase() JSTL Function Example explains about how to check whether a given input string contains the particular substring in a case intensive way.

Consider an example where you need to check whether the given input string is available on that particular string strictly in a case intensive way.

fn:containsIgnoreCase() JSTL function will check whether a given input string provided contains the particular substring in a case intensive way.

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

You can see the below example, which is demonstrating fn:containsIgnoreCase() JSTL Function

Required Libraries

You need to download

  1. Tomcat 7
  2. JSTL 1.2

Following jar must be in classpath

  1. jstl-1.2.jar

fn:containsIgnoreCase() Example

<%@ 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:containsIgnoreCase</title>
</head>
<body>

<c:set var="str" value="This is a TEST String"/>

<c:if test="${fn:containsIgnoreCase(str, 'test')}">
   <p>test in smallcase<p>
</c:if>

<c:if test="${fn:containsIgnoreCase(str, 'TEST')}">
   <p>TEST in uppercase</p>
</c:if>

</body>
</html>
Output
test in smallcase
TEST in uppercase

 






Your email address will not be published. Required fields are marked *