-Context
package com.gluegent.maya; import java.io.IOException; import javax.servlet.GenericServlet; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; public class ContextCheckServlet extends GenericServlet { public void init() throws ServletException { super.init(); log("init()"); ServletContext context = getServletContext(); log("context is " + (context == null ? "null" : context.toString() )); } public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException { log("service()"); } }
これをconf/web.xmlに登録してみると。。。
2005-04-11 18:15:28 StandardContext[/balancer]contextChack: init()
2005-04-11 18:15:28 StandardContext[/balancer]contextChack: context is org.apache.catalina.core.ApplicationContextFacade@d1e233
2005-04-11 18:15:28 StandardContext[/manager]contextChack: init()
2005-04-11 18:15:28 StandardContext[/manager]contextChack: context is org.apache.catalina.core.ApplicationContextFacade@10efd7c
2005-04-11 18:15:28 StandardContext[/jsp-examples]ContextListener: contextInitialized()
2005-04-11 18:15:28 StandardContext[/jsp-examples]SessionListener: contextInitialized()
2005-04-11 18:15:28 StandardContext[/jsp-examples]contextChack: init()
2005-04-11 18:15:28 StandardContext[/jsp-examples]contextChack: context is org.apache.catalina.core.ApplicationContextFacade@10deb5f
2005-04-11 18:15:28 StandardContext[/servlets-examples]ContextListener: contextInitialized()
2005-04-11 18:15:28 StandardContext[/servlets-examples]SessionListener: contextInitialized()
2005-04-11 18:15:28 StandardContext[/servlets-examples]contextChack: init()
2005-04-11 18:15:28 StandardContext[/servlets-examples]contextChack: context is org.apache.catalina.core.ApplicationContextFacade@221e9e
2005-04-11 18:15:28 StandardContext[/tomcat-docs]contextChack: init()
2005-04-11 18:15:28 StandardContext[/tomcat-docs]contextChack: context is org.apache.catalina.core.ApplicationContextFacade@11a01dd
2005-04-11 18:15:29 StandardContext[/webdav]contextChack: init()
2005-04-11 18:15:29 StandardContext[/webdav]contextChack: context is org.apache.catalina.core.ApplicationContextFacade@1367e28
ほう、なるほど。ちょっと思ってなかった動きでした。デフォルトで設定したものは各WEBアプリケーション毎に動くのか。。。となると、思いこんでた原因とは違いますね。