fn:indexOf() JSTL Function

fn:indexOf() JSTL Function Example explains about How To Use fn:indexOf() JSTL Function inside JSP.
Consider an example string where you need to find the first occurrence of a specified substring.
fn:indexOf() returns the index within a string of the first occurrence of a specified substring.
int indexOf(java.lang.String, java.lang.String)
you can see the below example, which is demonstrating fn:indexOf() JSTL Function
Required Libraries
fn:indexOf() Example
// Use Of JSTL fn:indexOf(String String) tag <%@ 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:indexOf() Example</title> </head> <body> <% // you can also set the values into request scope same as using c:set // request.setAttribute("str", "This is a Test String"); %> <c:set var="str" value="This is a Test String" /> ${fn:indexOf(str, "Test")} </body> </html>
Output
10