JSTL fn:indexOf() function

The JSTL fn:indexOf() function returns the start position of the specified string in the input string. It returns -1 if specified string not found in the input string.

Syntax:

int indexOf(String inputString, String specifiedString)

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>


	
		fn:indexOf JSTL function example
	
	
		
		Index of JSTL in the String: 
		

web.xml


	
  
          test.jsp
  	


Output:

jsp example 57
 
Download this example.
 
Next Topic: JSTL fn:join() and fn:split() function with example.
Previous Topic: JSTL fn:escapeXml() function with example.