Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on Statefull Session Bean

 
shannuv
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

Regards.
 
Bhanu
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic