If one is using a statefull session bean, how does one get a handle to it from one JSP page to the other JSP page.
Joined: Feb 17, 2005
First of all you might be aware that this is not a good practice with SFSB. This especially because SFSBs suppose to be single threaded and in case of receiving two concurrent requests from two different clients, your container might throw an exception. The second observation it�s a common problem with ejb handles: if the container passivates/removes the bean instance, then your handle is useless. Having said that, you have two choices: either to add the handle to the session or to serialize the handle to a common directory. For the first case you still have to worry about the case when your server fails and the session needs to be recovered. In this case you might recover your handle or you might not. The second scenario will save the handle in all circumstances. You need your first JSP to serialize the handle like this:
While the second JSP will get the handle from the common folder:
I think, therefore I exist -- Rene Descartes
Joined: Dec 05, 2004
As Valentin explained, It is not a good practice to share the handle of SFSB. Further, Serializing the handle in a common subfolder is again a risk. In most corporate applications, load balancing is very common and folder can not be shared. So keeping in that mind, think about better viable solution to your need.
Thanks,<br />Bhanu<br />SCEA Step-I<br />SCBCD for J2EE 1.3<br />SCJP1.4