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

孤街浪徒 提交于 2019-12-14 02:22:23

问题


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.


回答1:


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:

  • Get JSF managed bean by name in any Servlet related class
  • How do servlets work? Instantiation, sessions, shared variables and multithreading


来源:https://stackoverflow.com/questions/20244697/accessing-a-session-scoped-jsf-managed-bean-in-a-servlet-is-this-guaranteed-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!