JSTL fn:length() function

The JSTL fn:length() function is used to get the length of the object. It returns no. of characters in case of string input and no. of elements in case of collection.

Syntax:

int length(String inputString/Collection object)

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:length JSTL function example
	
	
		
		Length of the given string: 

web.xml


	
  
          test.jsp
  	


Output:

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