You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by James Howe <jw...@allencreek.com> on 2001/01/03 20:19:13 UTC

Configuring Struts for Tomcat + Apache

Can anyone offer some tips (or samples) of ways to configure Struts in a 
Tomcat + Apache environment?  I want to be able to serve static content 
from my web application from Apache but servlet code obviously needs to go 
to Tomcat.  Getting Tomcat to work with a new web application seems as easy 
as putting a .war file in the webapps directory, but it seems that more 
work is involved in getting Apache to do its part.  For example, if I 
access my web app directly from Tomcat with a URL like this:

http://localhost:8080/myapp

I get the index.jsp page which is defined as my welcome page.  However, if 
I use the URL

http://localhost/myapp

I get the directory of files in my web application.

If anyone can offer tips on how best to configure my Apache+Tomcat 
environment to support Struts applications, I would appreciate it.

Thanks.


Re: Configuring Struts for Tomcat + Apache

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
James Howe wrote:

> At 11:43 AM 1/3/2001 -0800, you wrote:
> >James Howe wrote:
> >
> > > Can anyone offer some tips (or samples) of ways to configure Struts in a
> > > Tomcat + Apache environment?  [...]
> >
> >There are two things you have to configure in httpd.conf to make this work:
> >
> >* Tell Apache that JSP pages can be used as welcome pages:
> >
> >     DirectoryIndex index.html index.jsp
> >
> >* Tell Apache to forward "*.do" URIs to Tomcat so that
> >   Struts can process them (assumes you are using MOD_JSERV):
> >
> >     AddHandler jserv-servlet .do
>
> That helps quite a bit but I have one additional question.  When running
> straight Tomcat, I can deploy a new web application by simply putting the
> WAR file in the webapps directory.  I can then access the application thusly:
>
> http://localhost:8080/fooapp
>
> (assumes fooapp exists in the webapps directory).  However, it seems as if
> I need to modify the tomcat.conf file referenced by apache to define an
> alias for my application something along the lines of:
>
> Alias /fooapp C:\Web\tomcat\webapps\fooapp
> <Directory "C:\Web\tomcat\webapps\fooapp">
>      Options Indexes FollowSymLinks
> </Directory>
> <Location /fooapp/WEB-INF/ >
>      AllowOverride None
>      deny from all
> </Location>
> <LocationMatch /fooapp/*.jsp>
>      SetHandler jserv-servlet
> </LocationMatch>
> <LocationMatch /fooapp/*.do>
>           SetHandler jserv-servlet
> </LocationMatch>
>
> If I want my user to enter something like
>
> http://localhost/fooapp
>
> and have Apache serve static stuff and Tomcat serve servlet stuff, do I
> need to update my tomcat.conf file everytime I add a new web application to
> the webapps directory?
>

For Tomcat 3.x you do have to do this.  The web connector currently being built
for Tomcat 4.0 does not -- it will require only a single "mount" type command per
webapp.

>
> Thanks again.
> James W. Howe                   mailto:jwh@allencreek.com
> Allen Creek Software, Inc.              pgpkey: http://ic.net/~jwh/pgpkey.html
> Ann Arbor, MI 48103

Craig



Re: Configuring Struts for Tomcat + Apache

Posted by James Howe <jw...@allencreek.com>.
At 11:43 AM 1/3/2001 -0800, you wrote:
>James Howe wrote:
>
> > Can anyone offer some tips (or samples) of ways to configure Struts in a
> > Tomcat + Apache environment?  [...]
>
>There are two things you have to configure in httpd.conf to make this work:
>
>* Tell Apache that JSP pages can be used as welcome pages:
>
>     DirectoryIndex index.html index.jsp
>
>* Tell Apache to forward "*.do" URIs to Tomcat so that
>   Struts can process them (assumes you are using MOD_JSERV):
>
>     AddHandler jserv-servlet .do

That helps quite a bit but I have one additional question.  When running 
straight Tomcat, I can deploy a new web application by simply putting the 
WAR file in the webapps directory.  I can then access the application thusly:

http://localhost:8080/fooapp

(assumes fooapp exists in the webapps directory).  However, it seems as if 
I need to modify the tomcat.conf file referenced by apache to define an 
alias for my application something along the lines of:

Alias /fooapp C:\Web\tomcat\webapps\fooapp
<Directory "C:\Web\tomcat\webapps\fooapp">
     Options Indexes FollowSymLinks
</Directory>
<Location /fooapp/WEB-INF/ >
     AllowOverride None
     deny from all
</Location>
<LocationMatch /fooapp/*.jsp>
     SetHandler jserv-servlet
</LocationMatch>
<LocationMatch /fooapp/*.do>
          SetHandler jserv-servlet
</LocationMatch>

If I want my user to enter something like

http://localhost/fooapp

and have Apache serve static stuff and Tomcat serve servlet stuff, do I 
need to update my tomcat.conf file everytime I add a new web application to 
the webapps directory?

Thanks again.
James W. Howe                   mailto:jwh@allencreek.com
Allen Creek Software, Inc.              pgpkey: http://ic.net/~jwh/pgpkey.html
Ann Arbor, MI 48103


Re: Configuring Struts for Tomcat + Apache

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
James Howe wrote:

> Can anyone offer some tips (or samples) of ways to configure Struts in a
> Tomcat + Apache environment?  I want to be able to serve static content
> from my web application from Apache but servlet code obviously needs to go
> to Tomcat.  Getting Tomcat to work with a new web application seems as easy
> as putting a .war file in the webapps directory, but it seems that more
> work is involved in getting Apache to do its part.  For example, if I
> access my web app directly from Tomcat with a URL like this:
>
> http://localhost:8080/myapp
>
> I get the index.jsp page which is defined as my welcome page.  However, if
> I use the URL
>
> http://localhost/myapp
>
> I get the directory of files in my web application.
>
> If anyone can offer tips on how best to configure my Apache+Tomcat
> environment to support Struts applications, I would appreciate it.
>

There are two things you have to configure in httpd.conf to make this work:

* Tell Apache that JSP pages can be used as welcome pages:

    DirectoryIndex index.html index.jsp

* Tell Apache to forward "*.do" URIs to Tomcat so that
  Struts can process them (assumes you are using MOD_JSERV):

    AddHandler jserv-servlet .do

  (There is an analogous setting for MOD_JK, but I do not
  remember it off the top of my head).

>
> Thanks.

Craig