JSTL Functions - contains() Function

The fn:contains() function determines whether an input string contains a specified substring.

Syntax:

The fn:contains() function has following syntax:

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

JSTL 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 Tutorial</title>
</head>
<body>
<c:set var="str" value="Suresh marks : 190"/>
<c:if test="${fn:contains(str, 'marks')}">
   <p>Found Lower Case String<p>
</c:if>
<c:if test="${fn:contains(str, 'MARKS')}">
   <p>Found Upper Case String<p>
</c:if>
</body>
</html>

Output :

Found Lower Case String