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

state in stateful session bean

 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends
i am new to ejbs, i want to know how session is maintained in stateful session beans. I have done lots of programming in servlets and jsp using httpsession. but in ejb we are not using http protocol so httpsession can not be used.
thanx in advance
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The session is maintained through SessionContext in statefullbean.
Gowrish
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The state for a stateful session bean is maintained as fields in the object.

If the container has to passivate the bean (maybe it has to make "room" for other more active beans), it might serialize the thing to a file on disk. Before the client uses it again, it will be deserialized and the bean activated. But all you care (as the developer) is that you wrote an object and the data is referenced by fields.
But think about why you are using stateful session beans. They can be misused and put a burden on the server.
Just because it has "session" in its name does not mean it is anything at all like the http session object. It is not a replacement.
I usually prefer to keep the ejb's api stateless, and let the client keep the state. If the client is a webapp, this means the client's state is in http session. If the client is a java program, it means keeping the state in that program's memory.
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your response, what i understand is in servlet/jsp same instance serves many client hence instance variables can not be use to store client's information while in stateful session bean one instance serves only one client hence that bean can store client specific information in instance variable.
correct me if i am wrong.
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right.
 
Trust God, but always tether your camel... to this tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic