Re: web.xml and ip-based virtual hosts

2003-01-26 Thread Craig R. McClanahan


On Sun, 26 Jan 2003, Marcin Gryszkalis wrote:

> Date: Sun, 26 Jan 2003 20:32:04 +0100
> From: Marcin Gryszkalis <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: web.xml and ip-based virtual hosts
>
> Hi
> I have Tomcat 4.1.x
> in configuration there's  block that contains two
>  blocks (I have 2 ip/port-based virtual hosts).
>
> 1. How can I specify in application's web.xml which 
> should it be deployed to?
>

You can't make this determination inside the web.xml file -- instead, the
determination is made in one of two ways, depending on how you've
configured the app in server.xml:

* If you created a  element for your webapp,
  it belongs to the  that encloses the 
  element you put it inside.

* If you didn't create   element (because you're
  relying on the automatic deployment feature), you will
  note that each  element has an "appBase" parameter.
  The webapp will belong to the  that surrounds
  the  element whose "appBase" directory you put the
  webapp inside.

> 2. Can I have ip-based virtual hosts with one serice
> and multiple ? I guess it's not possible
> because there can be only one DefaultContext per Host
> (and only one Host/Engine per service).
>

The  element does not define an actual webapp - it defines
a bunch of default settings for automatically deployed webapps.  The
default settings are per-host.

However, it is perfectly legal to have more than one  per
.

The overall structure of the server.xml file lets you do pretty much
any combination of things you want to do.  Consider the following, for
example (only the important parts called out):

  



  

  

  


  ... Optional  element ...
  ... Optional  elements ...


  






  

  

  


  ... Optional  element ...
  ... Optional  elements ...



  ... Optional  element ...
  ... Optional  elements ...


  



  

You might recognize the first  entry as pretty much what the
default Tomcat configuration looks like.  It has the following
characteristics:

* All incoming requests on port 8080 and 8081 are processed here.

* No matter what server name or IP address is used on the request,
  they are all processed by the "localhost"  element, as long
  as the DNS addresses resolve to this server.

* You can optionally nest a  element to define the
  characteristics of all automatically deployed webapps for this host.

* All web applications in the "$CATALINA_HOME/webapps" directory
  are automatically deployed at startup time.

* In addition, you can nest  elements with a "docBase" that
  points at your application's directory or WAR file.  Relative
  pathnames are resolved against the "appBase" (in this case, against
  "$CATALINA_HOME/webapps"), while absolute pathnames tell Tomcat
  exactly where to find your app.

The second  entry is quite a bit different.  It has the following
characteristics:

* All incoming requests on port 8082 and 8083 are processed here.

* Only host names "www.mycompany.com" and "www.yourcompany.com" are
  recognized (because there is no "defaultHost" element on this ).
  Any request for a different hostname that is received on these
  ports will be rejected.

* For each host, you can optionally nest a  element to
  define the characteristics of all automatically deployed webapps
  for this host.

* All web applications in the "$CATALINA_HOME/mycompany" directory
  will be automatically deployed for the www.mycompany.com host
  (relative paths are resolved against $CATALINA_HOME).

* All web applications in the "/foo/yourcompany" directory
  will be automatically deployed for the www.yourcompany.com host
  (absolute pathnames are legal as well).

* In addition, you can nest  elements under either 
  for additional webapps for that host, with a "docBase" attribute
  defining where the webapp is on your filesystem.  Absolute paths
  are resolved relative to the "appBase" directory for your host,
  while absolute paths (by definition) tell Tomcat where the webapp
  files are.

For further information about all of the elements you can create in
server.xml, see the Configuration Reference information, included in your
Tomcat install or available online:

  http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/

> regards
> --
> Marcin Gryszkalis
> http://fork.pl
> <><

Craig McClanahan



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




web.xml and ip-based virtual hosts

2003-01-26 Thread Marcin Gryszkalis
Hi
I have Tomcat 4.1.x
in configuration there's  block that contains two
 blocks (I have 2 ip/port-based virtual hosts).

1. How can I specify in application's web.xml which 
should it be deployed to?

2. Can I have ip-based virtual hosts with one serice
and multiple ? I guess it's not possible
because there can be only one DefaultContext per Host
(and only one Host/Engine per service).

regards
--
Marcin Gryszkalis
http://fork.pl
<><


--
To unsubscribe, e-mail:   
For additional commands, e-mail: