• 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

session managment and StateFul Session Beans

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41915
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic