• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on Statefull Session bean  RSS feed

 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
why do I need a statefull session bean , since it remembers client calls ??
if so , why cant I use a stateless bean with HttpSession object as a parameter to it. Why is it still in existence even though everyone say that its quite a burden ??
Please help me
manas
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manas Ahlaad:
if so , why cant I use a stateless bean with HttpSession object as a parameter to it.

You can use an HttpSession to store session state instead of a Stateful Session Bean and many people do. However, I wouldn't go passing the HttpSession object around the EJB layer...
Using the HttpSession may be an alternate for storing session state in web clients but it cannot completely replace Stateful Session Beans. What if your clients are not web clients and you want to store session state on the server? You would have to use something like Stateful Session Beans since using an HttpSession would not be an option.
Originally posted by Manas Ahlaad:
Why is it still in existence even though everyone say that its quite a burden ??

Stateful Session Beans have their uses, they are just not as prevalent as Stateless Session Beans. Besides, removing them from the EJB Specification would break backwards compatibility.
[ May 05, 2003: Message edited by: Chris Mathews ]
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if you stored SB reference on the Httpsession, that doesnot preclude the ejb container from using the same bean instance to service other clients. Therefore it will not guarantee exclusivity....
 
Geeta Ramasami
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
With session U have to always ensure that the session doesn't expire so that the data put in the session is never lost.Whereas with statful bean the data can be stored in instance variables which can be activate dand passivated accordingly.
Cheers
Geeta
 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi manas
Yes,outside the web context session beans stateful have their share merits.Replicating the statefull session bean functionality using stateless session bean will call for the a user information object to be passed to server every time the client issues a request,this will,in my opinion cause a network overhead.
Even in the web client context moving the session info(if present in large amounts)out of the HttpSession object to the session bean stateful will make sense from performance point of view.
william
 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello ajith,
why do i need exclusivity?
i am bothered with the bean remembering me betweeen calls and do functionality no matter what instance serves me .
what do u say ? any benefits with the exclusivity
thanks
Manas
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manas Ahlaad:
hello
why do I need a statefull session bean , since it remembers client calls ??
if so , why cant I use a stateless bean with HttpSession object as a parameter to it. Why is it still in existence even though everyone say that its quite a burden ??
Please help me
manas


This post is very similar from what you asked... hope it helps
 
Paul Lester
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am bothered with the bean remembering me betweeen calls and do functionality no matter what instance serves me .

Here is where I think that your confusion is: Stateful Session Beans are dedicated to one client. No other client has access to the same instance. Further, since they maintain state, you cannot call methods concurrently on them.
Stateless Session Beans can serve many clients during their lifetime.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!