• Post Reply Bookmark Topic Watch Topic
  • New Topic

session managment and StateFul Session Beans

 
Lalit Nagalkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I recently started trying my hands on J2EE web app development and am stuck to following questions about Stateful Session Beans(SfSB), I'll be glad to all of you for clearing my doubts and helping me:-

1> to create shopping cart like application is it necessary to put the SfSB instance for current user in session scope, if so then can't we do same with stateless session beans?

2> servlets does seesion managment using HttpSession class. But I think SfSBs doesnt have such provision, then how do these beans recognize which request is from which user and is part of a session, in both cases i.e. when beans are in active mode or when the passivated beans are reactivated?


3> in shopping cart like applications what are other ways that can manage sessions (making use of MVC and EJBs)?

thanks in advance
lalit
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
410
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lalit,
1) It is traditional to save user data in the HttpSession rather than a stateful session bean. If you are just practicing, it is ok to put the data in the SFSB though. You still don't want to put the SFSB in the HttpSession though. It contains references that the container should manage for you.

2) The container takes care of linking the user session to the SFSB .
 
Lalit Nagalkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply,

So does it mean even if don't use HttpSession my ShoppingCart will be taken care of automatically by the container?
 
Lalit Nagalkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DO you mean to say SFSB should not be used to save session data?

But SFSB is the only EJB that is meant to act on behalf of client(the end user) so the sesion data is ought to be saved in SFSB. OR do we create a new SFSB every time client accesses it and save required data in HttpSession, but then again it can also be done with SLSB as the purpose of such a bean would be just to execute a method and return as is done by SLSB.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!