fn:length tag of Function Tag Library

What is "fn:length" tag of Function Tag Library?


"fn:length" is a string function of JSP Standard Tag Library(JSTL).This string function is used to return the number of elements from an array or a collection, characters from a string.



In the above syntax the "value" can be of any data type.

Example :

<%@ taglib uri="http://java.sun.com/jsp/jstl/core"
prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions"
prefix="fn" %>
<p>Enter your new username:<input type="text" name="usr" size="25">
<input type="submit" value="Submit">
Length of your username is::
<c:out value="${fn:length(param.usr)}" />

In the above example the length of the username is displayed when the form is submitted by getting the attribute value using "param.usr" for the text box.

Ask Questions

Ask Question