File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 2902

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
Similar Threads
Login/Register based web page presentation
Sue's book
struts tag library vs JSTL
Adding Value in ArrayLisy WITHOUT SCRIPTING
DynaValidatorForm values in JSPs