Size of collection in a JSP/DSP page

leaf pile on Flickr

(Photo: leaf pile by oeimah)

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.

  
  
  Number of Pages: 
  Number of Pages: 

Here is an example of how to use JSTL 1.1 and DSPEL to get the size of a collection.

 

  
  Number of Pages: 


Leave a Reply

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