The <fn:containsIgnoreCase()> function is a string function of JSTL. This function is used to check whether the entered string contains the specified substring irrespective of upper case or lower case. This function returns the boolean value.
Syntax of Function <fn:containsIgnoreCase()>
boolean:fn:containsIgnoreCase(string,substring)
Example of Function <fn:containsIgnoreCase()>
In the above syntax string and substring are of data type String it returns the boolean value.
<%@ 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:containsIgnoreCase() example</title> </head> <body> <c:set var="string1" value="Welcome to JavaBeat.net"/> <c:set var="string2" value="javabeat" /> <c:if test="${fn:containsIgnoreCase(string1, string2)}"> <c:out value="String1: Welcome to JavaBeat.net contains"/><br><br> <c:out value="String2: javabeat"/> </c:if> </body> </html>
Details of the Code
- < c:set var=”JavaBeat” value=”Welcome to javabeat.net”> tag is used to set the variable name which we want to display in the output.
- <c:if test=”${fn:containsIgnoreCase(JavaBeat, ‘JavaBeat.net’)}”> this line of code
checks whether the entered string contains the specified substring irrespective of upper case or lower case.
Steps for Execution
- Save this file as example.jsp in your eclipse IDE.
- Now select this jsp file, right mouse click and select Run as ->Run on server
Output
When the execution process is completed successfully we will get the following output :
Previous Tutorial : JSTL Function fn:contains() :: Next Tutorial : JSTL Function fn:endsWith()