• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Direct access from JSP to EJB in Petstore appilcation

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic