aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB 3 Session beans: Stateless or Stateful Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 3 Session beans: Stateless or Stateful " Watch "EJB 3 Session beans: Stateless or Stateful " New topic
Author

EJB 3 Session beans: Stateless or Stateful

Sumit Bhoyar
Greenhorn

Joined: Oct 06, 2008
Posts: 14
I am new to EJB3. Most of the time, it is recommended to use stateless session bean while developing the application. So I was wondering, do we really need stateful session bean in web application, where user's state can be maintained by servlet container?
As per my understanding, we should use stateful session bean only when service is exposed to thick client or remote client, where there is no way to maintain the user session.
Please let me know your views.
Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 491
    
    1

Your question is really interesting. I do not know an answer, anyway I'd like to extend your question with an additional consideration. Let's have a remote client which communicates with a remote application server. Even in this scenario it's possible to use stateless EJBs: all conversational state may be mantained by the client (in this case a client should send to the server all data needed for processing) or by the application server itself. In fact, an HttpSession-equivalent concept (an "EJBSession" ) may be implemented like an HashMap, in which store the conversational state. Such scenario
would be schematized as follows:

a) Client and server exchange a SessionID.
b) Each request from client to server simple passes SessionID as parameter, so that EJBs stateless may keep conversational state.

Is it a foolish idea ? Often I read that EJBs stateless are considerably faster than stateful ones, so I wonder if they are really necessary....


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB 3 Session beans: Stateless or Stateful