What is the difference between stateful and stateless
session beans?

Answers were Sorted based on User's Feedback



What is the difference between stateful and stateless session beans?..

Answer / pn8572

Stateful Session bean - the session bean which is associated with one EJB client.

example : normal item cart in any online shopping site.

Stateless Session bean- each session bean can be reused by multiple EJB clients.

example : EMI calculator.

Is This Answer Correct ?    10 Yes 1 No

What is the difference between stateful and stateless session beans?..

Answer / 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

More EJB Interview Questions

What does it mean to be stateless?

0 Answers  


why object class is a parent of all classes in java?

2 Answers   TCS,


What is Enterprise JavaBeans Query Language (EJB QL)?

0 Answers  


Is it possible to write two ejb’s that share the same remote and home interfaces, and have different bean classes? If so, what are the advantages/disadvantages?

0 Answers  


What are the callback annotations for the stateless bean?

0 Answers  






What happens when I change a value in the httpsession from inside an ejb?

0 Answers  


What is ejb and its properties?

0 Answers  


Why is ejb used?

0 Answers  


What is ejb in java?

0 Answers  


What are the design goals of EJB architecture?

1 Answers  


What is a stateless session?

0 Answers  


What do you mean by ejb?

0 Answers  


Categories