• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to maintain session info between a servlet and a session bean  RSS feed

 
Jim Baker
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to use a servlet to call a session EJB.
Since there is only one instance of servlet in
a web container, how can a stateful session
know which client is calling it? Should I use
stateless sessionbean and pass
HttpSession obj from servlet to the stateless
session bean?
Any comments?
JB
 
Kirt Henrie
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the best way to accomplish that would to keep the remote reference (EJBRemote) to the statefull session bean in the clients http session.
KJ
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way is to maintain stateless session beans and pass whatever data the bean needs to process the request.
 
Kirt Henrie
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I misread the question, I also suggest completely avoiding (and I do) stateful session beans if it is an option.
I did read a white paper by Borland that argued keeping state in the ejb tier for clustering purposes on their app sever, other than that I have seen no reason to do so.
KJ
 
Jim Baker
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
What about an application client? Should
I use stateless session bean and pass over
everything? I know the scalability of stateless
session baen is better that statful session
bean, but in the mean time passing over everything will increase
the network load.
JB
 
Kirt Henrie
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess that depends on what you need to pass the bean. Typically because the client should be separate from the controller the only thing the client should need would be the data it is going to display. When you make requests to the server it should only need to pass in filter data (for grids), form data, etc.. which would need to be passed over one way or the other. In the stateful session bean model, you might actually increase network overhead by not having a local copy of result sets, etc. which would require a download each time you need them.
I am still thinking stateless would be the way to go.
 
Jim Baker
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think we need to pass everything in
stateful ejb case, but just the change to the
previous state info.
If we are using stateless session ejb, I
think we are going back to the old way: client
maintain the session.
It it's true, it seems to me only useful EJB is stateless session EJB.
JB
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!