• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Problem in understanding session beans

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I am a novice in ejb and I am finding it very hard to understand stateful and stateless session beans. As we all know stateful session beans are used when we want to maintain a state. Here as per my understanding is maintaining a session by the container. Such as what all activities are being done in a particular session.

To implement this I made a very small program of stateless and stateful session bean and connected this ejb module with struts via Guice DI framework.

The following is my stateful and stateless code:-






Here both the interfaces are remote.


My problem is:-
Whenever I call a struts action method method which internally calls the stateless session bean from one particular browser the bean is initialized (only once for one browser) and the value of i is incremented by 1. This increment happens each time i call the bean method. If i call stateless session bean from another browser a new stateless session bean is created, and its postconstruct method is executed and the value of i is initialized.

However when i call a method that calls the stateful session bean, each time i call the stateful session bean from the same browser, it is initialized and a new value of i is used. It has become so confusing for me.

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