my dog learned polymorphism*
The moose likes EJB and other Java EE Technologies and the fly likes HttpSession object VS StatefulSession Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "HttpSession object VS StatefulSession Bean" Watch "HttpSession object VS StatefulSession Bean" New topic
Author

HttpSession object VS StatefulSession Bean

Tina Desai
Ranch Hand

Joined: Mar 13, 2003
Posts: 365
Hi Friends,

The following question keeps popping up in discussions and
I need some help on this.

"We can maintain the session using the HttpSession object, then why
do we need stateful session beans?"

Thank you in advance!

Regards,
Tina


Alongwith being a good coder, try to be a good professional as well!
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
An enterprise EJB application must be designed to support various types of client, eg web, Swing, web service, EJB. For such an app, I would say that conversational state should usually be maintained in the business logic layer using stateful session beans. (Another alternative is to store state in the DB, which is secure but slow.) And if you store state in the web tier, this will result in duplicate data storage for the web clients.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
For one reason, if you want to use the bean services through some other means, say WAP, you need stateful-ness of the beans.

From a professional/business point of view, the web layer and the business layer should be decoupled as loose as possible in design. Beans are business objects and such an object, where necessary, should maintain state. When we design the work flow, we design to requirements and not to technology.

It is upto us to strike a deal, judiciously, of course, whether we can maintain state using HTTPSession or EJB's, though both give us options.


keep smilin :: sravan<br /><a href="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
Tina Desai
Ranch Hand

Joined: Mar 13, 2003
Posts: 365
Thank you to both of you Roger and Coffee. Very to the point and clear replies. I got it now.

Coffee, sorry if this feels a little ungrateful at this moment. We have a Naming Convention on Javaranch. You may want to take a look at the link

Regards,
Tina
 
GeeCON Prague 2014
 
subject: HttpSession object VS StatefulSession Bean