INTERNATIONAL INSTITUTE OF INFORMATION TECHNOLOGY
P-14, Pune Infotech Park, Hinjawadi, Pune – 411 057
Enterprise JavaBeans: Understanding Session Beans
Session beans were first introduced in March of 1998 when Sun Microsystems published the EJB 1.0
A session bean is one type of enterprise bean that resides in EJB container. Session beans model business
processes. They provide a robust way for handling sessions in a J2EE application.
What Is Conversational State?
Client/server interaction typically involves multiple request/response roundtrips. A
is a single client's
interaction with a server. The session state is client-specific data that is accumulated during the session.
This session state is also known as
The conversational state can be maintained in the client, the server, or split between them. For example, the
contents of the temporary shopping cart can be maintained in the client side or in the server object's
instance variables. The division of responsibility is based on factors such as performance, security, and so
The use of session beans to maintain client interactions is the standard method in any J2EE application. As
their name implies, session beans were designed with this purpose in mind. Services such as security,
concurrency, and transactions are provided to session beans by the container.
What Are Session Beans?
A session bean implements a conversation between a client and the server side. Session beans execute a
particular business task on behalf of a single client during a single session. They implement business logic
such as workflow, algorithms, and business rules.
You can think of a session object as extension of client on the server side. It works for its client, sparing the
client from complexity by executing business tasks inside the server.
For example, a session bean can send email, help in workflow management, and implement algorithms
such as compression, encryption, and so on.
Session bean clients can be from the EJB tier, as other session beans, from the Web tier, as servlets and
taglibs, or they can be from the client tier as a J2EE client. The session bean by itself implements the
business logic. The container provides functionality for remote access, security, concurrency, transactions,
and so on.
Session Bean Files
Like other enterprise beans, a session bean consists of the home interface, the component interface, the
bean class, and the deployment descriptor.
The home interface is either a remote home interface or local home interface. A remote home
interface extends the javax.ejb.EJBHome interface, whereas a local home interface extends
javax.ejb.EJBLocalObject. The home interface is used as the bean factory. The client uses the
home interface to manage the life cycle of the session bean.