Sometimes in a JSP/DSP page you will want to get the size of a collection and unless you are within a Range, ForEach or similar droplet you won’t have access to this value.
Struts has a nice solution using the bean:size tag. JSTL 1.1 has a nice solution using the fn:length function.
Here is an example of how to use Struts, DSPEL and JSTL to get the size of a collection.
<dspel:getvalueof param="book.pages" var="pages" vartype="java.util.Collection"/> <bean:size id="numPages" name="pages"/> Number of Pages: <c:out value="${numPages}"/> Number of Pages: <dspel:valueof value="${numPages}"/>
Here is an example of how to use JSTL 1.1 and DSPEL to get the size of a collection.
<dspel:getvalueof param="book.pages" var="pages" vartype="java.util.Collection"/> Number of Pages: <c:out value="${fn:length(pages)}"/>