Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fundamental doubt in SLB

 
Nijeesh Balan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a fundamental doubt in Stateless Session Beans. If i have instance variables in Stateless Session Beans will it behave like a stateful session bean inspite of mentioning session bean type as Stateless in the xml file.
Plz clarify.
Thanks in Advance,
Nijeesh.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, u can maintain the state using stateless session bean if the container returns u the same instance every time u access, which cannot be assumed ...


Originally posted by Nijeesh BH:
Hi,
I have a fundamental doubt in Stateless Session Beans. If i have instance variables in Stateless Session Beans will it behave like a stateful session bean inspite of mentioning session bean type as Stateless in the xml file.
Plz clarify.
Thanks in Advance,
Nijeesh.
 
Nandu Arni
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why should we use instances variables inside a stateless session bean. If we use, how can we initialize. if you initialize thru create method..it will be a statefull.
Incase of stateless session bean, the connection is set for every method call irrespective of the client accessing the bean.
So it all depends on the vendor implenting the container, conceputually it sould not store the state of the instance variables between the method calls.
but incase if weblogic and websphere, the state of the instance variables defined inside a stateless bean are still maintained.
The idea od SLSB is not to use instance variables.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic