Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

stateless vs stateful session beans

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain me the difference between stateful and stateless session beans?

Also it would be more helpful if i can get scenarios when to use stateful or when to use stateless , with respect
to a web application
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference is just that one has state, the other doesn't. This means that every call to a stateless bean is distinct. The EJB session is analagous to an HttpSession (which you are maybe familiar with?) so its just a way of storing data in memory that pertains to a specific user. Make any sense?
 
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stateless Session bean has pool of instances whereas Stateful does not have...

Stateful Session bean instances are created for each Client on the fly... So Client state information can be saved and can be used for next business method call..

In Stateless beans, Only one bean instance serves all the Client... So, in next business method call, bean does not have the trace of past information...

 
Rajiv Chelsea
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ram

In your reply you told , Stateless Session bean has pool of instances ..

Then again you say that Only one bean instance serves all the Client..

If only one bean instance is supposed to serve all the clients, then why is a pool of instances required?

Also it will be better if I can get an example of a scenario where to use stateful session bean
and where to use stateless session beans with respect to a single web-application
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In Stateless beans, Only one bean instance serves all the Client...


This isn't right. There could be 1, or more instances (up to the number in the pool)
 
Rajiv Chelsea
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any provide examples please?
 
Ram Narayan.M
Ranch Hand
Posts: 247
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to display a list of books borrowed by particular customer of a library, giving the customer name as a key, List of books can be returned from stateless session bean method... This is an example of doing Bean managed persistence where querying Database are done by Stateless session bean itself... A search key is given and in return the result corresponding to that key is returned...
 
    Bookmark Topic Watch Topic
  • New Topic