This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes c:if  syntax error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "c:if  syntax error" Watch "c:if  syntax error" New topic
Author

c:if syntax error

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
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

Joined: Jan 10, 2002
Posts: 61084
    
  66

You cannot call instance methods in the EL. In other words, no calls to size().


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

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.
 
wood burning stoves
 
subject: c:if syntax error