ServletContext
来源:互联网 发布:淘宝叫顾客给好评话术 编辑:程序博客网 时间:2024/05/16 18:05
一、ServletContext,是一个全局的储存信息的空间,服务器开始,其就存在,服务器关闭,其才释放。
request,一个用户可有多个;
session,一个用户一个;
而servletContext,所有用户共用一个。所以,为了节省空间,提高效率,
ServletContext中,要放必须的、重要的、所有用户需要共享的线程又是安全的一些信息。由于一个WEB应用中的所有Servlet共享同一个ServletContext对象,因此Servlet对象之间可以通过ServletContext对象来实现通讯。
ServletContext context = this.getServletContext();
//存入共享的数据
context.setAttribute("name", "haha");
//获取共享的数据
String name = context.getAttribute("name");
0 0
- ServletContext
- ServletContext
- servletcontext
- servletContext
- servletContext
- servletcontext
- ServletContext
- ServletContext
- servletContext
- ServletContext
- ServletContext
- servletContext
- ServletContext
- servletContext
- ServletContext
- servletContext
- ServletContext
- servletcontext
- linux中fork()函数详解
- 批量下载文件
- Wireshark 抓包指南
- Android AES加密解密
- 域名直接访问到项目
- ServletContext
- Android studio 之ANalyze 清理无用资源
- POI导出EXCEL经典实现
- Redis学习笔记(十一)Redis-benchmark为Redis性能测试工具
- ffmpeg的转码延时测试与设置优化
- android adt版本号问题
- Intellij Idea中Backspace无法使用,Insert和全选错乱等问题的解决
- atom 阿童木怎么加snippet片段,函数注释
- Log4j日志在java项目中的使用