This Function Returns the index within a string of the first occurrence of a substring.
This function returns the index of a specified substring from the string. In this program we firstly call the syntax library of JSTL functions for accessing them. After in the body section we declare attributes and the ‘var’ variables that will contain the storing value in it. The main occurrence will be to declaring the string function as we declare. After that close all the html tags. The function we call will present the output on the web browser.
fn:indexOf.jsp
<%@ 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:indexOf> In JSTL</title>
</head>
<body>
<c:set var=”str1″ value=”Welcome To World Of Java Server Pages.”/>
<c:set var=”str2″ value=”Welcome to Java and JSTL Functions”/>
<b><center><p>The Output as Index (1) : ${fn:indexOf(str1, “Java”)}</p>
<b><center><p>The Output as Index (2) : ${fn:indexOf(str2, “Functions”)}</p>
</body>
</html>