tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: Apache & Tomcat cooperation
Date Mon, 10 Jul 2000 15:56:43 GMT
"Rob S." wrote:

> > Now I guess I'd still have to have a look at the server.xml file
> > at least if I want to specify to TomCat that I want Apache to
> > process the static HTML files & images, wouldn't I?
>
> That's one thing I've never been quite sure about, but I really should be =)
>
> For example, let's say you mount your default context to the root of a
> virtual host.  Will all requests to that host be sent to Tomcat, even ones
> that are for HTML and images?  If so, it would seem as though mounting a
> context under a certain path and wanting Apache to serve static files under
> that same path while mounted would be mutually exclusive goals.
>
> Anyone mind shedding some light on this?
>

The "$TOMCAT_HOME/conf/tomcat-apache.conf" file that is generated automatically
every time you start Tomcat attempts to set things up so that static files are
served by Apache, while JSP pages and servets are executed by Tomcat.  It does
so by generating a series of Apache configuration directives for each context
that you've defined in your server.xml file (plus those that are automatically
recognized in the webapps directly in Tomcat 3.2).  For the /examples context,
the generated commands look like this:

    Alias /examples "/path/to/tomcat/webapps/examples"
    <Directory "/path/to/tomcat/webapps/examples">
        Options Indexes FollowSymLinks
    </Directory>
    ApJServMount /examples/servlet /examples
    <Location "/examples/WEB-INF/">
        AllowOverride None
        deny from all
    </Location>

In English, these commands roughly do the following:

* Whenever Apache sees a request that starts with
  "/examples", go to the specified directory on your
  disk.  This causes static files to be served from here
  by Apache unless overridden elsewhere (see below).

* When serving static files, apply the usual Indexes
  and FollowSymLinks options

* Any request that starts with "/examples/servlet" should
  be passed on to Tomcat's "/examples" context for
  execution (i.e. run a servlet).

* Do not serve any static files from "/examples/WEB-INF"
  (this follows the servlet spec rule that you are not allowed
  to serve these files directly to a client.)

There is an additional rule at the top of the file that causes all JSP pages to
be executed by Tomcat:

    AddHandler jserv-servlet .jsp

The mechanism in the generated file is not perfect (for example, it doesn't know
about any <servlet-mapping> entries you have defined in your "web.xml" file),
but it gives you a starting point for integrating Tomcat with Apache.  For more
information, see the "Minimalistic User's Guide" document included with Tomcat,
and the standard Apache configuration documentation.

>
> - Rob

Craig McClanahan



Mime
View raw message