Tomcat容器中相关对象的生命周期
来源:互联网 发布:淘宝网拍模特兼职 编辑:程序博客网 时间:2024/06/02 04:15
1、Tomcat中相关对象的生命周期
(1)ServletContext:应用程序生命周期内,被所有Request和Session共享
(2)Servlet、Filter、Listener:应用程序生命周期内,被所有Request和Session共享
(3)HttpSession:客户端(浏览器)不关闭(同一实例),并且在Server中没有过期,被所有持有相同Session的Request共享
(4)HttpServletRequest、HttpServletResponse:一次请求到响应输出完毕,不共享
2、Servlet和Filter非线程安全
不能将Request或Session级别的数据赋值给Servlet或Filter的实例变量
public class ExampleServlet extends HttpServlet { private Object thisIsNOTThreadSafe; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Object thisIsThreadSafe; thisIsNOTThreadSafe = request.getParameter("foo"); // BAD!! Shared among all requests! thisIsThreadSafe = request.getParameter("foo"); // OK, this is thread safe. } }
阅读全文
0 0
- Tomcat容器中相关对象的生命周期
- spring容器对象的生命周期
- 容器中Bean的生命周期
- 容器中Bean的生命周期
- 容器中Bean的生命周期
- tomcat 容器生命周期lifecycle
- tomcat 容器生命周期lifecycle
- 容器,对象生命周期管理的基石
- spring容器创建对象的生命周期
- Spring-----9、容器中bean的生命周期
- Spring容器中Bean的生命周期
- Spring容器中Bean的生命周期
- Spring IOC容器中Bean的生命周期
- Spring容器中Bean的生命周期
- Spring 容器中 Bean 的生命周期
- IOC容器中bean的生命周期
- Spring 容器中Bean的生命周期
- Spring IOC容器中Bean的生命周期
- java 变量的内存空间及数据类型
- 文件上传
- 6.标签包含规范
- UVA 11995:I Can Guess the Data Structure!(水)
- 手把手教你用R语言建立信用评分模型(完结篇)— —打分卡转换
- Tomcat容器中相关对象的生命周期
- PAT(Basic Level)_1039_到底买不买
- TF-day2 神经网络基础知识
- 防守打法
- Lintcode94 Binary Tree Maximum Path Sum solution 题解
- The type java.lang.reflect.Type cannot be resolved异常的处理
- 执行shell时某些操作使用sudo执行又不想每次输入密码的解决方式
- 链表的逆转(头插法)
- JVM垃圾回收算法及回收器详解