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中有一个ServletContextsession
增长了动态增长servlet, filter等函数.app
ServletContext中也能够放置Attributes来和Servlet Container交互, 可是都是存在在一个JVM上的, 不可能跨JVM存在.jsp
另外, 提供了一些对于配置的API, 主要是关于三者: Servlet, Filter ,ContextListener; 具体在编程时参考Javadoc分布式
全部绑定到同一个Context上的Servlet能够访问一样的一些attribute object. 事实上, 该类属性是被分配在JVM上的一块共享空间的, 若是须要在分布式的环境下使用, 则须要把这些属性放在session,或者是database,或者JavaBean中.ide
ServletContext访问静态资源的方法, 以下:函数
getResource getResourceAsStream
两个函数都是先搜寻Context所在的根目录, 而后是WEB-INF/lib下面Jar包中的META-INF/resources目录, 可是搜寻Jar包下资源的顺序是不定的.可是对于动态资源如jsp, 则是不适用的, 须要根据分发请求来决定.code
当多台服务器公用一个IP地址的时候, 会使用"virtual hosting", 而每一台host应该拥有独立的servlet context, 之间不能被共享.server