Stateless, Stateful, and Entity Beans

EJB allows for several types of beans: stateless, stateful, and entity. As you progress from stateless to entity, the beans offer more functionality, but at the cost of more required coding.

Stateless Beans

The easiest bean type, and the one you'll look at first, is a stateless session bean. Session beans are usually likened to verbs in English; they are used for actions, such as adding something to the database or computing a value.

Stateless session beans are throwaway objects. They are maintained in a pool on the EJB server. They keep no state between calls, and they operate strictly on the data passed in via the call.

Stateful Beans

Stateful session beans are allowed to maintain state between calls. By ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.