Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checking size of an arrayList

 
Saptarshi Chakraborty
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic