This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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: 65111
89
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: 65111
89
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