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
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
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
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.
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