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>&lt;fn:indexOf&gt; 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>

          JSTL fn:indexOf() Function





About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.