fn:length tag of Function Tag Library

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

Explanation

"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.

Syntax:


int:fn:length(value)

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" %>
<html>
<form>
<p>Enter your new username:<input type="text" name="usr" size="25">
<input type="submit" value="Submit">
</form>
<br>
Length of your username is::
<c:out value="${fn:length(param.usr)}" />
</html>

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