• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB 3 Session beans: Stateless or Stateful

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....


 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic