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

Session Bean

 
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. I have problem in understanding the word state in Stateless/Stateful session bean in context to servlets i.e, web applications. Is the stateful session bean similar to a HttpSession? Can they be used alternatively?
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
HTTPSession represents the user session accessing your application.
Stateful session bean maintains the state of the client in between different service/method invocation on that bean.
Generally you put the handle of the Stateful session bean in the HttpSession. This handle can be retrieved from the HttpSession.getAttribute() and then SFSB method can be invoked on the same.

Stateless Session beans - They are not supposed to maintain the client state between method invocation. The instance of the SLSB being used to serve the client's request is transparent to the client.

Regards,
amit
 
Poornima Sharma
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 Amit,

You mean that once we have injected a stateful session bean in a web application, we should keep that SFSB object in HttpSession and use it wherever needed, just like other bean objects. Is this the process to maintain state of the bean?

Thanks,
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
I am not sure about Injection.
I mentioned the approach earlier where we had done the lookup of SFSB and then store the handle of it in HttpSession.
State of the bean will be maintained by the container and not you. You only map the instance of the SFSB to the User (logged in probably) using the HttpSession.

Hope this helps, though you need to wait for some answer on the injection aspect of your question.

regards,
amit
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic