This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Checking size of an arrayList" Watch "Checking size of an arrayList" New topic

Checking size of an arrayList

Saptarshi Chakraborty

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: 2904

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]
I agree. Here's the link:
subject: Checking size of an arrayList
jQuery in Action, 3rd edition