What is difference between stateless and stateful session beans?


In this post, we will see the differences b/w stateless and stateful session beans.

Stateless Session Bean:

  • Stateless session bean do not maintain state across method calls and transactions
    The EJB server transparently reuses instances of the Bean to service different clients at the per-method level (access to the session bean is serialized and is 1 client per session bean per method.
  • Used mainly to provide a pool of beans to handle frequent but brief requests. The EJB server transparently reuses instances of the bean to service different clients.
  • Do not retain client information from one method invocation to the next. So many require the client to maintain on the client side which can mean more complex client code.
  • Client passes needed information as parameters to the business methods. Performance can be improved due to fewer connections across the network.

Stateful Session Bean :

  • A stateful session bean holds the client session’s state.
  • It is an extension of the client that creates it.
  • Its fields contain a conversational state on behalf of the session object’s client.
    This state describes the conversation represented by a specific client/session object pair.
  • lifetime of these are controlled by the client and cannot be shared between clients.

3 thoughts on “What is difference between stateless and stateful session beans?

  1. Bedsgergisp May 15, 2010 / 2:45 pm

    Just want to say what a great blog you got here!
    I’ve been around for quite a lot of time, but finally decided to show my appreciation of your work!

    Thumbs up, and keep it going!

    Cheers
    Christian

  2. Medicali Glass June 6, 2014 / 3:45 am

    I was suggested this web site by my cousin. Iam not sure whether tis post is written by him
    as no one else know such detfailed about my problem.
    You are amazing! Thanks!

  3. social media body image January 12, 2017 / 12:44 pm

    You actfually makе it seеm soo easy ᴡith yⲟur presentation buut І fіnd ths topic tо be realⅼy ѕomething tһаt Ⅰ think Ι աould nevr understand.
    It ѕeems toо complex and vеry broad for me. Ι’m ⅼooking forward for үour next post,
    I ԝill try to gett the hang off іt!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.