my dog learned polymorphism*
The moose likes JSP and the fly likes PetStore cart.jsp question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "PetStore cart.jsp question" Watch "PetStore cart.jsp question" New topic
Author

PetStore cart.jsp question

Peter Lee
Greenhorn

Joined: Jun 25, 2003
Posts: 24
HI all,
Referring to Petstore 1.3.2 source code cart.jsp, why in following line 5, it can refer to cart directly without declaring cart before?
1: <%@ taglib prefix="waf" uri="/WEB-INF/waftags.tld" %>
2: <%@ taglib prefix="c" uri="/WEB-INF/c.tld" %>
3: <%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %>
4: <c:choose>
5: <c:when test="${cart.count == 0}">
6: <p class="petstore_title">Your Shopping Cart is Empty.</p>
7: </c:when>
Thanks.
Regards,
Peter
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61458
    
  67

In the EL, an unqualified name, such as cart in this example, is expected to be a scoped variable in one of page, request, session or application scopes. Because there is no qualification, the EL will search the scopes for "cart" in that order.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: PetStore cart.jsp question