• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

statefull session bean

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anybody tell me diffence between statefull session bean an d stateless session bean.
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe a stateless session bean is a special case of a session ejb that does not keep any information related to its client whereas stateful session beans would contain information particular to the client that created it and maintains this information until removed.
 
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The stateful session bean is bound to the client that has instanciated it.
The stateless is back to the pool each time a client does not use it anymore (end of each method call). Thus the Stateless is shared between clients but the Stateful is specific to each client.
Most of the time (IMHO), stateful is used to simulate a conversational state in HTTP (which is a stateless protocol)
HTH.

[This message has been edited by Bill Bailey (edited November 28, 2001).]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,
my doubt is not cleared, I want to know how the state will be maintained by the container? either it by any serialization? or any session object?

thanks and regards
Ravi
 
Saloon Keeper
Posts: 24517
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The session bean has passivation and activation methods. These are called by the container if there is a need to free up resources. Once passivated, the bean should be capable of being serialized by the container, and once deserialized, the activation method should restore the bean to a condition indistinquisable from its pre-passivation state.
Without actually checking the spec, I don't think that the passivation/activation mechanism is required to use Java serialization. I think that's left up to the container implementer.
Despite the name, "session" EJBs have no relation whatsoever with http server sessions outside of the fact that an http session can contain EJBs in the same way it can contain other Java objects.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Heres my attempt at an explanation
Stateful session bean - holds state during the lifetime of the session bean.
Stateless session beans - only have state during a method call and therefore the application server can make various performance improvements when it uses them.
An important thing to note is that the state is not persistent unless you code for it. The state is only available for the lifetime of the bean. Yes it maybe temporarily stored to disk due to passivation but that is for the app server to decide. If you need the data to be persisted you should be using an entity bean (or prehaps not). There is a long discussion on this at:
http://www.theserverside.com/home/thread.jsp?thread_id=9375
Hope that helps
Phil
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic