Easy Tutorial
❮ Jstl Function Startswith Jsp Jstl ❯

fn:containsIgnoreCase() Function

JSP Standard Tag Library

The fn:containsIgnoreCase() function is used to determine if a string contains a specified substring, ignoring case.

Syntax

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

<c:if test="${fn:containsIgnoreCase(<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"/>

&lt;c:if test="${fn:containsIgnoreCase(theString, 'tutorialpro')}">
   <p>Found tutorialpro<p>
</c:if>

&lt;c:if test="${fn:containsIgnoreCase(theString, 'tutorialpro')}">
     <p>Found tutorialpro<p>
</c:if>

</body>
</html>

The output is as follows:

Found tutorialpro

Found tutorialpro

JSP Standard Tag Library

❮ Jstl Function Startswith Jsp Jstl ❯