Use of Tag of JSTL

In this section, will learn how to use Tag of JSTL.

Use of <fn:length(String)> Tag of JSTL


In this section we will learn how to use <fn:length> Tag of JSTL. This tag returns the number of items in a collection, or the number of characters in a string. This takes Object type as arguments and returns int type.

Syntax :
int length(java.lang.Object)


<%@ taglib prefix="c" uri="" %>
<%@ taglib prefix="fn" uri="" %>
        <title>Example of fn:length tag of JSTL</title>
        <form method="POST">
            This will calculate the length of specified string.
                    <td>Enter String</td>
                    <td><input type="text" name="text"></td>
                    <td><input type="submit" value="calculate"></td>
        <c:if test="${pageContext.request.method=='POST'}">
            <c:set var="text" value="${param.text}"/>
            <font size="5" color="#1B2A0A">
                Length : 
            <font size="5" color="green">

                <c:out value="${fn:length(text)}"/>

This jsp code shows the following output :

Suppose in user wants to calculate the length of string 'mahendra singh'.....

When user clicks on calculate button, output will be.....

Download Source Code

Share on Google+Share on Google+

Use of Tag of JSTL

Posted on: August 24, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Use of Tag of JSTL   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image