fn:contains() JSTL Function
fn:contains() JSTL Function Example explains about how to Tests whether the input string contains the particular substring.
Consider an example where you need to check whether the given input string is available on that particular string.
fn:contains() JSTL function will tests whether the input string contains the particular substring.
boolean contains(java.lang.String, java.lang.String)
You can see the below example, which is demonstrating fn:contains() JSTL Function
Required Libraries
fn:contains() 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:contains</title> </head> <body> <% // you can also set the values into request scope same as using c:set // request.setAttribute("str", "hello"); %> <c:set var="str" value="hello" /> ${fn:contains(str,"he")}<br/> ${fn:contains(str,"hellow")} </body> </html>
Output
truefalse