• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic