You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hua Hou <hu...@handango.com> on 2003/04/23 23:38:28 UTC

Question with ServletContext.getContext(anotherContextName) under TomCat

All,

I am trying to achieve inter-context communication between different
contexts by using ServletContext.getContext(context name) API. I set up the
server.xml as following:

      <Host name="siteA.mycompany.com" debug="0" appBase="webapps" 
       unpackWARs="true" autoDeploy="true">
        <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="microsoft_log." suffix=".txt"
	        timestamp="true"/>
          <Context path="" docBase="siteA" crossContext="true" debug="0" />
          <Context path="/core" docBase="core" crossContext="true" debug="0"
/>
          <Context path="/include" docBase="include" crossContext="true"
debug="0" />
      </Host>

My physical directory structure is:

webapps\core
webapps\include
webapps\siteA

Within a jsp in "siteA" directory, the following code returns null:

context.getContext("/core").getResourceAsStream("foo.jsp");

Although I do have foo.jsp under directory "core".

But within a jsp in "include" directory, the above code works perfectly
fine. It does returns me the file as InputStream.

Is it because the path for siteA is ""? Any way to make it work?

Your help are greatly appreciated.

Thanks.

Hua



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org