在Servlet中访问会话范围内的JSF托管Bean,是否保证该会话与JSF使用的会话相同? [英] Accessing a session scoped JSF managed bean in a servlet, is this guaranteed to be the same session as JSF uses?

查看:93
本文介绍了在Servlet中访问会话范围内的JSF托管Bean,是否保证该会话与JSF使用的会话相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用

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

如果要尝试调用SessionScopped托管bean:这将确切知道要调用哪个bean实例(与当前负责调用的用户相关联的实例).如果许多用户同时使用servlet,此过程是否安全? 我还想知道是否有可能在Servlet上使用实体bean.

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.

推荐答案

如果两者都部署在同一服务器和上下文中,那么,是的,JSF肯定使用与Servlet完全相同的HTTP会话.作为基于Servlet的MVC框架,JSF只是在标准Servlet API之上运行,并将托管bean作为会话属性存储,而托管bean名称作为键.

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.

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

这篇关于在Servlet中访问会话范围内的JSF托管Bean,是否保证该会话与JSF使用的会话相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆