aspose file tools*
The moose likes Struts and the fly likes Checking size of an arrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Checking size of an arrayList" Watch "Checking size of an arrayList" New topic
Author

Checking size of an arrayList

Saptarshi Chakraborty
Greenhorn

Joined: Jul 26, 2007
Posts: 23
hi folks,

How can i know the size of an ArrayList through any of the struts logic tag and EL or JSTL?
I am sending an arraylist consisting of several objects from action and before iterating it in jsp I want to check whether the arraylist is not null or its size is greater than zero. To solve it I don't want to use scriptlet .Please try to provide the solution with struts logic tag,EL or jstl.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Saptarshi Chakraborty wrote:I want to check whether the arraylist is not null ...

I advice never to return a "null" arraylist, instead return an empty arraylist.
Still, if you can't change underlying code, and set the null array, I suspect it won't get included in any scope as its null.
so, if you have case like this:


Saptarshi Chakraborty wrote:or its size is greater than zero.

To check size, Two possible solutions
- the empty keyword
- the fn:length function (not available in JSTL1.0)


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
jQuery in Action, 2nd edition
 
subject: Checking size of an arrayList