What is the difference between stateful and stateless
session beans?

Answer Posted / kunwar dharmendra singh

Stateful vs. Stateless Session Beans
A stateful session bean will maintain a conversational state
with a client. The state of the session is maintained for
the duration of the conversation between the client and the
stateful session bean. When the client removes the stateful
session bean, its session ends and the state is destroyed.
The transient nature of the state of the stateful session
bean should not be problematic for either the client or the
bean, because once the conversation between the client and
the stateful session bean ends, neither the client nor the
stateful session bean should have any use for the state.

A stateless session bean will not maintain conversational
states for specific clients longer than the period of an
individual method invocation. Instance variables used by a
method of a stateless bean may have a state, but only for
the duration of the method invocation. After a method has
finished running either successfully or unsuccessfully, the
states of all its instance variables are dropped. The
transient nature of this state gives the stateless session
bean beneficial attributes, such as the following:

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate Conversational from Non-conversational interactions?

545


What does ejb stand for?

618


What are the various types of entity beam?

548


What are ejbs used for?

501


What is ejb framework?

561






What is the difference between message driven beans and stateless session beans?

519


Explain what is an EJB Context?

617


What is ejb and its types?

515


What is stateless session bean?

554


What is mdb in ejb?

519


What’s the difference between hibernate and ejb 3?

549


What is an entity manager?

530


How many enterprise beans?

544


List some key actors in persistence api.

554


What is ejb and why it is used?

503