1

When calling a managed bean in a servlet using

MyBean myBean = (MyBean) request.getSession().getAttribute("myBean");

if it's about trying to call a SessionScopped managed bean : will this know exactly which bean instance to call (the one associated to the current user who was responsible of making the call). will this process be safe in case where many users use the servlet in the same time ? I want also know if it is possible to use an entity bean on a servlet.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Bardelman
  • 2,176
  • 7
  • 43
  • 70
  • 1
    Why do you want to call a JSF managed bean from a servlet in the first place? – Nikos Paraskevopoulos Nov 27 '13 at 14:27
  • why u think this is useless :), i had to get some properties from it. – Bardelman Nov 27 '13 at 14:56
  • well, i think that yes, the jsf container knows how to associate each managed instance to each specific user. Even when using @Inject , there is no additional parameters to specify to let the servlet exactly which bean instance to call. – Bardelman Nov 27 '13 at 15:02

1 Answers1

2

If both are deployed on the same server and context, then, yes, JSF definitely uses the very same HTTP session as the servlet. JSF as being a servlet based MVC framework just runs on top of the standard servlet API and stores managed beans as session attributes with the managed bean name as key.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555