JSTL Functions – contains() Function

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


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" %>

<title>JSTL Tutorial</title>

<c:set var="str" value="Suresh marks : 190"/>

<c:if test="${fn:contains(str, 'marks')}">
   <p>Found Lower Case String<p>

<c:if test="${fn:contains(str, 'MARKS')}">
   <p>Found Upper Case String<p>


Output :

Found Lower Case String