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

c:if syntax error

 
Raj Ohadi
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a session object "CART" that is a List, In my JSP I have

<c:if test="${!empty sessionScope.CART and sessionScope.CART.size() > 0}">
// proess things
</c:if>

But it complains the syntax error. I don't know why ?? All I want to do is to check if the CART is not null and has more than one element..

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64711
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot call instance methods in the EL. In other words, no calls to size().
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64711
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, you don't need to do the size check anyways. The empty operator will return true if the operand is null or if it is empty.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic