Accessing a session scoped JSF managed bean in a servlet, is this guaranteed to be the same session as JSF uses?

StackOverflow https://stackoverflow.com/questions/20244697

Question

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.

Was it helpful?

Solution

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:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top