Stateless as the name suggests do not store the user/any other information. So they are used only as business logic minus the user information mechanisms. Can be used where u wanna do some processing irrespective of which user is using the bean. They are used generally as one per many clients. Stateful session beans are beans that keep the user/other info. i.e. they maintain the state information. Like in a typical shopping cart where u have to keep a track of which user does what. They are normally one per user and their state is written to a temporary store in case more than 1 users use the same StatefulSB and the container automatically switches context depending on which user has the current handle to the bean. HTH Sahil
Hi, Stateful session beans maintain conversational state when used by client. Conversational state means, the beans state is kept in memory while a client uses a session (but it is not written to a database though). Maintaining conversational state allows a client to carry on a conversation with a bean. As each method on a bean is invoked, the state of the session bean may change, and the change can affect subsequent method calls. So for the subsequent method calls the client will get the updated state of the bean. Conversational state is kept for as long as the client application is actively using the bean. Once the client shuts down or releases the bean, the convesational state is lost forever. Stateful session beans are not shared among clients, but they r dedicated to the same client for the life of the bean. On the other hand stateless session bean do not maintain any conversational state. Each method is completely independent and uses only data passed in its parameters. So stateless session beans r shared among the clients and a single bean instance can serve multiple clients. Hope u get cleared to some extent.. for detailed explanation with example, refer Enterprise JavaBeans by oreilly publications.. Saran
The mechanism used to store the state... You just need to pass the parameters you want to be stored in the conversational state through the ejbCreate method(s) of the stateless bean.
Joined: Jan 30, 2001
suzi, stateless beans generally do not store the state, only stateful do .... in case u want that u'r stateless session beans shud store the state u have to write the state(variables) to a temporary storage before a context switching(new user taking over) occurs. Or else and better let tthe stateful beans do it as this is their job. HTH Sahil
Joined: Jan 05, 2001
Sorry, i meant the stateful session benas..i know that stareless session beans do not store the state........ I do know that we need to pass in parameters thru the create method, but i wnat to know the mechanism inside to store the state. Tx, Suzi