On Fri, 13 Dec 2002, Johnson, Garrett wrote:

> Date: Fri, 13 Dec 2002 14:00:59 -0500
> From: "Johnson, Garrett" <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: 'Tomcat Users List' <[EMAIL PROTECTED]>
> Subject: Difficult sections in server.xml and web.xml...
>
> Ladies and Gentlemen:
>
> I'm afraid I can't seem to wrap my head around a few things in the web.xml
> and server.xml files in configuring Tomcat:
>
> In server.xml:
>
> * What does the <Host> node mean?  If I set <Host name="localhost"> does
> that make a difference than if I set it for <Host name="foobar">?  Does the
> name attribute have real significance or is it just an ID?
>

The <Host> element lets you ask Tomcat to answer requests for more than
one host name, within the same instance of Tomcat.  (NOTE -- your DNS
server must map the various host names to the IP address of your server).
The name must match the DNS name that is assigned.

When a request comes in, Tomcat checks the "Host" header and finds a
matching <Host> element.  If there are none, it sends the request to
whichever host name you've declared as the "defaultHost" on the
surrounding <Engine> element.

In an out-of-the-box Tomcat install, there is a single <Host> element
named "localhost", and this is also the defaultHost setting.  That's why
it is able to answer requests for any valid hostname for your server.

For more info on server.xml configuration values:

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

> In web.xml, (sitting in a context directory,):
>
> * For the <servlet> node:
>       * Is the servlet-name attribute merely an ID?
>       * What is the display-name attribute for?
>

The servlet name is an ID.  The display name element is available for use
by GUI tools that help you assemble webapps -- it doesn't have any direct
influence on the execution of your app.

> * For the <servlet-mapping> node:
>       * Is the servlet-name attribute ALSO merely an ID?

Yes -- it is the ID that is used to match this mapping to a particular
servlet with the same name.

>       * What is the syntax for the url-pattern attribute?  Can I use
> wildcards?  Reg. Expressions?

See Chapter 11 of the Servlet Specification:

  http://java.sun.com/products/servlet/download.html

or one of the large numbers of books about servlet programming.  There's
also more information in the Application Developer's Guide included with
Tomcat, or available online at:

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


>
> * Finally, is there any relationship between the <Context> node in the
> server.xml file and the web.xml?

There can be a <Context> element for each web application that is deployed
inside Tomcat.  (You don't need an explicit <Context> element for webapps
that are automatically deployed in the $CATALINA_HOME/webapps
subdirectory, if the default settings work for you).

Within a webapp directory, you must obey the requirements of the servlet
spec for file organization, which includes having the web.xml file in the
/WEB-INF subdirectory.

>  Or is the only dependency that the web.xml
> file needs to be in docbase/WEB-INF, where docbase is the value of the
> docbase attribute in the <Context> nodes?

As you'll see in the configuration docs pointed to above, you can also use
an absolute pathname in the docBase attribute, and have your webapp
anyplace you like in the filesystem.

>
> Thanks in advance for any assistance y'all can provide.
>

Craig


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

Reply via email to