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

Confused about STFL and STLS beans

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm really confused about usage of STFL and STLS beans .
The main difference benwen them is that STFL can hold clients state and STLS can't. Thus I tried to test it with local client.
(1) Created 2 EJBs - StatelessBean and StatefullBean
(2) Deployed to Glassfish 2.1.1 AS. No any aditional configurations were made.





First time I called client and set "data" variable to 1 in STFL and STLS beans. By second call I just tried to obtain that value.
Results in fist time were as supposed:

But when calling second time I obtained following results:


There is no question about STFL - each time I obtain reference to new STFL bean thus value is 0. But why I obtained the same STLS bean
There is server.log



 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is exactly how stateless bean behaves, the server uses the same instance of the stateless bean to serve multiple clients requests.
That is why it is not recommended for you to keep state in the stateless bean as your instance may end up serving a totally different client.
To recap what I have just said, any instance of stateless bean in the pool can serve any client. However statefull session bean instance are attached to the client that created it and can't be reused by another client while it is in use.
 
Kiril Nugmanov
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hany Shafik,

Thanks for clearing the situation.
 
    Bookmark Topic Watch Topic
  • New Topic