what situations will we use a Stateful Session Bean to handle business logic ?
Stateful Session Bean should be used if you need to store a conversional state with the user. The typical scenario is the a shopping cart - the user puts the items into the cart one after the other and check out at the end. The Shopping card Stateful Session Bean stores the items that the user has chosen and encapsulates the business logic of calculating the order price, discounts etc. The main problem of the Stateful Session Beans is that they are more "ressource hungry" than the stateless session beans, since one Stateful Session Bean can serve only one client.
what situations stateless session bean?
Stateless Session Bean can be used if there is no conversional state with the user. One typical usage of the Stateless Session Bean would be a canceling the order: The user enter the order number and clicks on cancel, the code calls "cancel" method on a Stateless Session Bean and passes the order number as a parameter - everything that the bean needs to know about the request from the user must be passed as a parameter. One Stateless Session Bean can serve requests for more than one client which makes them more scalable.
what situations entity bean?
Entity beans should be used only from the stateless or the stateful session beans (one can use them in the presentation tier, but this creates usually a performance bottleneck). Entity beans are optional - their purpose is representing the persistent data, caching and storage manupulation. They should implement the storage logic - the business logic should be encapsulates in the session beans.