Servlet Context
Servlet Context
Container Provider 负责提供ServletContext的实现.
A ServletContext is rooted at a known path within a Web server. For example, a
servlet context could be located at http://www.mycorp.com/catalog . All requests
that begin with the /catalog request path, known as the context path, are routed to
the Web application associated with the ServletContext .
在每一个容器中都有一个ServletContext, 但是当容器被部署在不同的JVM上时, 每一个JVM中有一个ServletContext
Configuration methods
增加了动态增加servlet, filter等函数.
ServletContext中也可以放置Attributes来和Servlet Container交互, 但是都是存在在一个JVM上的, 不可能跨JVM存在.
另外, 提供了一些对于配置的API, 主要是关于三者: Servlet, Filter ,ContextListener; 具体在编程时参考Javadoc
Context Attributes
所有绑定到同一个Context上的Servlet可以访问同样的一些attribute object. 事实上, 该类属性是被分配在JVM上的一块共享空间的, 如果需要在分布式的环境下使用, 则需要把这些属性放在session,或者是database,或者JavaBean中.
Resources
ServletContext访问静态资源的方法, 如下:
getResource
getResourceAsStream
两个函数都是先搜寻Context所在的根目录, 然后是WEB-INF/lib下面Jar包中的META-INF/resources目录, 但是搜寻Jar包下资源的顺序是不定的.但是对于动态资源如jsp, 则是不适用的, 需要根据分发请求来决定.
Multiple Hosts and ServletContexts
当多台服务器公用一个IP地址的时候, 会使用"virtual hosting", 而每一台host应该拥有独立的servlet context, 之间不能被共享.
Servlet Context的更多相关文章
- Spring的servlet context和application context
Spring lets you define multiple contexts in a parent-child hierarchy. The applicationContext.xml def ...
- servlet context 和 servlet config
servletConfig Servlet容器初始化一个servlet对象时,会为这个servlet对象创建一个servletConfig对象,该对象中包含了servlet的<init-para ...
- INFO Dispatcher:42 - Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir
INFO Dispatcher:42 - Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax ...
- JavaWeb核心编程之(三.4)Servlet Context 配置
ServletContextServlet引擎为每个Web应用程序都创建一个对应的ServletContext对象, ServletContext对象被包含在ServletConfig对象中, 调用S ...
- Java Servlet规范
截自网址:http://blog.csdn.net/u010391029/article/details/46521051 JavaServlet Specification Version 2.3 ...
- context元素大概解说
Context元素代表一个web应用,运行在某个特定的虚拟主机上.如Servlet Specification 2.2或以后版本中描述的那样,每个web应用基于一个Web Application Ar ...
- Servlet 3特性:异步Servlet
解异步Servlet之前,让我们试着理解为什么需要它.假设我们有一个Servlet需要很多的时间来处理,类似下面的内容: LongRunningServlet.java package com.jou ...
- What is the difference Apache (Http Server) and Tomcat (Servlet Container)
The Apache Project The Apache Project is a collaborative software development effort. Its goal is to ...
- Context上下文对象(抄书的)
Servlet上下文 ServletContext 上下文接口 ServletContext接口 每一个应用都有唯一的一个上下文对象,即为ServletContext对象 Servl ...
随机推荐
- 做一名开源社区的扫地僧——从Bug report到Google Summer of Code(GSoC):从200个bug到5000美金
今年的软件自由日(SFD),我在广州Linux用户组的线下活动上做了一个分享,主题叫做<做一名开源社区的扫地僧(上)>.我把演讲的内容重新整理扩充, 写出了文字版, 希望可以跟更多朋友分享 ...
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">详解
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- httpd基础
hpptd http服务器应用 http服务器程序 httpd apache nginx lighttpd 应用程序服务器 IIS .asp tomcat .jsp jetty 开源的servlet容 ...
- AtCoder Beginner Contest 087 D People on a Line(DFS)
题意 给出n个点,m组关系L,R,D,L在R的左边距离D,判断是否存在n个人的位置满足m组关系 分析 Consider the following directed graph G: There ar ...
- 混用ngui和ugui渲染顺序问题
http://blog.csdn.net/xtxy/article/details/38332801 为NGUI panel 添加 sorting layer 接着上一篇文章的问题,看到了老外做的一个 ...
- 洛谷P3857 [TJOI2008]彩灯(线性基)
传送门 线性基裸题 直接把所有的状态都带进去建一个线性基 然后答案就是$2^{cnt}$($cnt$代表线性基里数的个数) //minamoto #include<cstdio> #inc ...
- perl 安装LOG4perl 模块
环境信息 ubuntu 12.04 64位 桌面版 Log-Log4perl 的介绍网址:http://search.cpan.org/~mschilli/Log-Log4perl-1.49/lib/ ...
- "字节跳动杯"2018中国大学生程序设计竞赛-女生专场
口算训练 #include <iostream> #include <algorithm> #include <cstring> #include <cstd ...
- element-ui + el-dialog + Vue.component 注册的富文本控件 第二次及以后打开dialog出现问题解决方法
自定控件 添加属性 v-if="dialogVisible" <el-dialog title="" :visible.sync="dialo ...
- 微信小程序使用字体图标
项目中常常需要使用到字体图标,微信小程序中使用字体图标与在平常的web前端中类似但是又有区别.下面以使用阿里图标为例子讲解如何在微信小程序中使用字体图标. 第一步:下载需要的字体图标 进入阿里图标官网 ...