O'Reilly logo

EJB 3.1 Cookbook by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a stateful session bean

In order to illustrate the creation of a stateful EJB, we will use a bean to maintain a list of names. A name will be entered in the index.jsp page and passed to a servlet. The servlet will add the name to the stateful bean. Unique to the stateful EJB is the process of passivation. When a stateful bean is experiencing a period of inactivity, the EJB container may decide to remove it from memory temporarily. This process is called passivation. Most of the state of the EJB is saved automatically except for transient fields. When the EJB is restored, the stateless EJB has its original content except for the transient fields.

Getting ready

Creating a stateful session bean requires:

  1. Annotating a class with the @Stateful ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required