Java Developer's Journal 2 of 6 Session beans control workflow. Due to their task-centric nature, the session beans are transient and not persistent. Session beans interact with entity beans and act as agents for client applications. A client application interacting with session and entity beans is presented in Figure 1. Having the workflow logic in a session bean rather than in the client application reduces the network traffic and the number of connections needed.
Session beans can be either stateful or stateless.
Stateful session beans maintain their state across multiple client requests and are useful for long-running conversational tasks. Multiple clients, however, can't share the same bean instance because the bean's state depends on a particular conversation with a client. Stateless session beans don't maintain any state. Each method invocation is independent of any previous invocation and operates only on data passed in as parameters. The same bean instance can serve multiple clients, thereby reducing the amount of resources needed to serve the clients.