I want an example of, how the a stateful Session Bean maintians the conversational state between client calls ?
I would like to quote a simple example. Suppose i access the stateful session bean in my jsp page. I first create the bean, then i call a method on the bean to set some variable. Now i go to the next jsp page. In the new jsp page, i want to read the session bean's variable which i have set in the previous jsp page. How can i achieve this ?
Someone told me that i need to keep the reference of hte bean's remote object in my HttpSession and access it in the next page.
But, i suspect, this can be done with stateless session bean also. If i use a stateless session bean in one of my jsp page, set some variable of the bean, put the bean's reference in my http session and try to access the bean in a new jsp page using the reference i have stored in the session. Can i do this ?
If yes, then how can i differentiate between the stateful and stateless session beans ?
What are the other aspects in which these two beans differ ?
If you want to maintain conversational state between client calls I think its best to use Statefull Session Beans.
When it comes to Statefull session beans there will be one-to-one mapping between number of clients available and number of bean instances available.
But when it comes to Stateless Session beans they might be re-used by the container to service the clients. So they can't hold the client states.
I think the reason you suspect that the same thing can be achieved by both Statefull and Stateless session beans are may be because you are just testing with one client (Browser or a client program). May be both behaves similarly when there is one client!!!