• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Statefull SessionBean or DomainObject in HTTP Session?

 
Marco Elb
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'am in doubt of using a statefull session bean or http session to store information collected in a workflow of an online store. The workflow is: load a list of products, choose a product, make some checks of the availability and then add it to a shopping cart. Later the customer checks out the shopping cart and he inputs his credit card information.

Normally I would introduce a vew stateless session beans for the businesslogic and crud operations. The loaded objects I would store in the http session. But for my seca assignment I am in doubt if sun expect me to use statefull session beans to store the shopping cart information.

Is there a best practice?

Regards,
Marco
 
Viggo Navarsete
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

did you get any feedback on your question? I'm also not sure how to model a shopping cart, either using the HTTP Session or a statefull session bean..
 
John Lincoln
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This topic has been discussed in the forum before. General consensus is to use http session. We should use Statefull bean only when it is absolutely necessary.

The main thing we are persisting is the shopping cart, with items and use of statefull in this scenario seems to be overkill

Hope this help

 
Viggo Navarsete
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for quick reply! I agree with the input given
 
Marco Elb
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I went the proposed way (from "John Lincoln"). It seemed to be okay for sun/oracle...

Regards,
Marco
 
Devashish Bansal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say if you have any such need as below then only go for SFSB :

It supports transaction service, security service, life cycle management, RMI, instance cache; thread safe etc. so one need not to write code for these services.
Both web based and non-web based clients can use it.
Multiple operations for a single http request can be processed.
 
Arnold Reuser
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best practices, as stated by Sun Blueprint program, advice to store session state in a SFSB in an EJB centric architecture and HttpSession in a Web centric architecture.
If there is any public advice, stated by Sun or Oracle, against this rule. Please let me know and provide a reference to support it.

To support this statement :
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html#1079299
4.4.7.3 Web-Tier State Recommendations
When using enterprise beans, it's best to maintain session state with stateful session beans in the EJB tier.
For Web-only applications, maintain the state in the Web tier as session attributes (using HttpSession).



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic