Forums Register Login

Http Session and stateful EJB state

+Pie Number of slices to send: Send
I know how http session is maintained between server and client : when server creates a session, it uses either cookie or URL rewriting to send back JSESSION ID which tracks session. Now if there is another stateful EJB involved here. suppose client calls a servlet on application server, this application server creates a session and invokes a stateful EJB which may run on another remote server. How is the stateful session EJB state maintained and what is its relationship with the http session ? Is that state maintained "inside" the http session ? could that state be terminated while session is still alive ? when session is killed would that state be still alive ?

Any explanation ? Thanks
+Pie Number of slices to send: Send
The state of an Ejb is maintained by the Ejb itself. A stateful EJBs is an Ejb instance dedicated to a single client. This means that in a stateful Ejb, you can safely assume that the same instance will be used across different method invocations, so that you can have instance variables maintaining the 'state' of the object. For example, you could set with a method call a list of product items, with another call you may set the customer's info and with a third invocation you can write an order. This scenario would be impossible wit stateless Ejbs: there is no guarantee that the same instance will b responding to two consecutive invocations of service by the same client.
In the HTTP session is stored only a stub of the remote Ejb.The stub will take care to invoke remote methods on the Ejb, but they re actually two different things. When you are done with a Ejb, you should remove it explicitly.Honestly I don't know what happens if, for example, the webserver is shut down without a clean up. I presume that remote Ejbs will survive, but they won't be accessible anymore resulting in a garbage.
I found a beautiful pie. And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 754 times.
Similar Threads
https and session state
URL Rewriting
a question about sessions ...
Managed Beans and Session Beans
Session vs Cookie objects
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:10:26.