• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stateful Session and Shopping Cart

 
Ranch Hand
Posts: 264
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I am playing around stateful session beans. So building a shopping cart simple demo for that. I am new to EJBs. So need to clear a doubt. We know Stateful session beans are used for more than one conversation between client and server. Here client is a Servlet. So when user first time enters or adds an item to cart, i fire a create(some arg, may be user name) and get a ref to remote component stub. Now item is added first time. and my first request to web client is done. The item is finally added in Session bean 's list.

We know that http is stateless. Next time, i cant get ref to remote component stub to the same bean. So do i need to store it into HttpSession for the same user session till the time user say confirm for all items and when user confirm, finally after buying those items, i need to call remove on ref to remote component stub or on home stub with Handle.

Please correct me if i am wrong here or tell me some good technique of this.

Thanks
Pawan
SCJP5.0, SCWCD 1.4
TARGET: EJB2.0 and the EJB3.0
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pawan,

I am new to EJB but I have also been thinking about servlets and session EJBs.

I think you are right: you need to store your stateful session bean's reference in the web application's session scope. Then when you are done using it, you should call one of the remove methods (e.g., one of the stateful session's beans methods annotated with the @Remove annotation) and then remove your stateful session bean's reference from session scope.
[ May 13, 2008: Message edited by: Sergio Tridente ]
 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. What is annotation here you are talking about. Is this feature being used in EJB3.0.
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pawan preet:
Thank you. What is annotation here you are talking about. Is this feature being used in EJB3.0.



Yes. With EJB 3, you just annotate your beans for the callbacks and actually much more.
 
reply
    Bookmark Topic Watch Topic
  • New Topic