• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Direct access from JSP to EJB in Petstore appilcation

 
Anatoli
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Petstore application has couple of places where JSP directly access EJB without ViewHelper in the middle.
For instance, cart.jsp has the following code:
<c:when test="${cart.count == 0}">
<p class="petstore_title">Your Shopping Cart is Empty.</p>

Cart is ShoppingCartLocal session EJB and is added as an attribute to the HTTPsession in PetstoreComponentManager.java class:
public void sessionCreated(HttpSessionEvent se) {
super.sessionCreated(se);
se.getSession().setAttribute(PetstoreKeys.CART, getShoppingCart(se.getSession()));
}

Similar, Customer.jsp has direct access to CustomerLocal Entity bean:
<td class="petstore_form" align="left"
colspan="2"><c ut value="${customer.account.contactInfo.givenName}"/></td>
</tr>
where customer is added as an attribute to the HTPPsession in SignOnNotifier.java class:
CustomerLocal customer = sl.getCustomer(session);
// ensure the customer object is put in the session
if (session.getAttribute(PetstoreKeys.CUSTOMER) == null) {
session.setAttribute(PetstoreKeys.CUSTOMER, customer);
}

Does this code contradict this Petstore class (component) diagram? See link below, figure 11.9:
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/app-arch/app-arch5.html.
The diagram does not have direct link between JSP and EJB.

Also, does it couple JSPs and EJBs together?

Any comments/explanations of the code above will be appresiated.
 
Anatoli
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is correct a link to class diagram in the post above:
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/app-arch/app-arch5.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic