File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes How the statefulsession beans maintain their state for each paricular client Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "How the statefulsession beans maintain their state for each paricular client" Watch "How the statefulsession beans maintain their state for each paricular client" New topic
Author

How the statefulsession beans maintain their state for each paricular client

kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
How the statefulsession beans maintain their state for each paricular client;

take for example shopping cart bean

will the session id created on each user and stored into the server?

if another user comes another session id created stored in to the server?

if the first client comes again how the server knows i should give this session id to this client
Al Petersen
Greenhorn

Joined: Nov 27, 2004
Posts: 9
A common question I get in classes. The answer is: the stateful session bean has NO IDEA who its client is. The client has to maintain the reference to the stateful session bean, not the other way around.

If the SFSB is a remote bean, you can call the method

to retrieve the beans handle (javax.ejb.Handle), which is a serializable reference to the EJBObject. Then you can store that handle someplace where you can get it again. For example, in a web application you can store the handle in the HttpSession. Later, when you want a connection to the stateful session bean, you take your handle and call

which returns the reference to the EJBObject for the stateful session bean (if the bean still exists.. if it doesn't you'll see a NoSuchObjectException)

Hope that helps,

- alan
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How the statefulsession beans maintain their state for each paricular client
 
Similar Threads
why need session?
Stateless and Stateful Session Beans
How Session & entity beans will react to too many client request?
Regarding conversational web services
Create Session in Restful Service.