tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Configuring which Servlet is invoked
Date Mon, 11 Oct 2010 10:31:57 GMT
Christopher Dodunski wrote:
> Hi,
> 
> Thanks, but I'm not quite clear on how to direct Tomcat to call the ROOT
> application for a given domain.  I added the bottom <Host> element to
> server.xml, but it doesn't appear to work correctly.
> 
> <Engine name="Catalina" defaultHost="localhost">
>   <Host name="localhost"  appBase="webapps" unpackWARs="true"
> autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
>   </Host>
>   <Host name="blog.christopher.net.nz" appBase="webapps/ROOT" />
> </Engine>
> 
> Previously, the URL http://blog.christopher.net.nz/christopher called up
> webapps/christopher, when it should instead have been handled by Apache
> Roller running with ROOT context.  Now that I have added the above
> directive, Tomcat reports "The requested resource () is not available".
> 
> The URL http://blog.bread.co.nz/bread is handled by Roller, as intended,
> because there is no competing application at webapps/bread.
> 
It is difficult to respond clearly to your questions, because they seem to be based on the

wrong premises, and/or they are confusing as to what you are really trying to achieve.
We also have no idea what the ROLLER application is, and how itself needs to be set up.

But here are some basic principles :

1) this line :
  <Engine name="Catalina" defaultHost="localhost">
indicates which one of your <Host> below, is the default host.
The default Host is the one which will handle any request which arrives at this server, 
and for which the hostname does not match one of the other <Host> tags.
In you case thus, this
<Host name="localhost"..
is the default Host.

2) each separate Host should have a separate "appBase", not overlapping the others.
So, having one Host with appBase="webapps", and another Host with appBase="webapps/xxxx" 
is a nono, you should not do that.
Create another directory, for example (tomcat_dir)/webapps-blog, and use that one to put 
the applications related to your host blog.christopher.net.nz, like
<Host name="blog.christopher.net.nz" appBase="webapps-blog" />
(You can also define this directory totally outside the hierarchy of the main Tomcat, like

at /var/websites/blog.christopher.net.nz, and then use
<Host name="blog.christopher.net.nz" appBase="/var/websites/blog.christopher.net.nz" />

3) within each "applications base" (appBase), each application will correspond to a 
directory, with the same name as the application.
So for example, under (tomcat_dir)/webapps/, you can have one application called "app1" 
and another called "app2", for a structure like this
   tomcat_dir/webapps/
                     app1/
                     app2/

4) To call any of these applications, you will use a URL like :
    http://host-name/app1
    http://host-name/app2
    etc..

5) the special name "ROOT" is reserved for the "default application" within a Host.
    That is the application which users would get if they simply entered
    http://host-name/

So, to modify the structure given above so that there would be, in addition to app1 anbd 
app2, a default application, you would have :

   a) a file structure like this :
   tomcat_dir/webapps/
                     ROOT/
                     app1/
                     app2/
and users could ask for :

    http://host-name/      (to get the default application)
    http://host-name/app1  (to get the app1 application)
    http://host-name/app2  (to get the app2 application)

Does this clarify things ?


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


Mime
View raw message