JSTL Function fn:length()

The function <fn:length()> is the string function. This function used to find out the length of the entered string. This function displays the number of characters entered in the specified string.

Syntax of Function <fn:length()>

int length(Object)

Example of Function <fn:length()>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<title>JSTL fn:length() example</title>
	<c:set var="string1" value="JavaBeat" />
	<c:set var="string2" value="welcome to JavaBeat.net" />
	Length of word JavaBeat is: ${fn:length(string1)}
	<br> Length of word welcome to JavaBeat.net is:


Steps for Execution

  • Save this file as example.jsp in your eclipse IDE.
  • Now select this jsp file, right mouse click and select Run as ->Run on server


When the execution process is completed successfully we will get the following output :
output of jstl function length

Previous Tutorial :  JSTL Function fn:substring()  :: Next Tutorial : JSTL Function fn:toLowerCase()

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!