| Links Top Level Elements Executors Connectors Containers Nested Components Cluster Elements Other | The Host Container| Introduction |  | 
  The Host element represents a virtual host,
  which is an association of a network name for a server (such as
  "www.mycompany.com" with the particular server on which Tomcat is running.
  For clients to be able to connect to a Tomcat server using its network name,
  this name must be registered in the Domain Name Service (DNS) server
  that manages the Internet domain you belong to - contact your Network
  Administrator for more information. In many cases, System Administrators wish to associate more than
  one network name (such as www.mycompany.comandcompany.com) with the same virtual host and applications.
  This can be accomplished using the Host
  Name Aliases feature discussed below. One or more Host elements are nested inside an
  Engine element.  Inside the Host element, you
  can nest Context elements for the web
  applications associated with this virtual host.  Exactly one of the Hosts
  associated with each Engine MUST have a name matching the
  defaultHostattribute of that Engine. Clients normally use host names to identify the server they wish to connect
  to. This host name is also included in the HTTP request headers. Tomcat
  extracts the host name from the HTTP headers and looks for a
  Host with a matching name. If no match is found, the request
  is routed to the default host. The name of the default host does not have to
  match a DNS name (although it can) since any request where the DNS name does
  not match the name of a Host element will be routed to the
  default host. 
    The description below uses the variable name $CATALINA_BASE to refer the
    base directory against which most relative paths are resolved. If you have
    not configured Tomcat for multiple instances by setting a CATALINA_BASE
    directory, then $CATALINA_BASE will be set to the value of $CATALINA_HOME,
    the directory into which you have installed Tomcat. | 
 | Attributes |  | 
  | Common Attributes |  | 
    All implementations of Host
    support the following attributes: | Attribute | Description | 
|---|
 | appBase | The Application Base directory for this virtual host.
        This is the pathname of a directory that may contain web applications
        to be deployed on this virtual host.  You may specify an
        absolute pathname, or a pathname that is relative to the
        $CATALINA_BASEdirectory.  See
        Automatic Application
        Deployment for more information on automatic recognition and
        deployment of web applications. If not specified, the default ofwebappswill be used. |  | xmlBase | The XML Base directory for this virtual host.
        This is the pathname of a directory that may contain context XML
        descriptors to be deployed on this virtual host.  You may specify an
        absolute pathname for this directory, or a pathname that is relative
        to the $CATALINA_BASEdirectory.  See
        Automatic Application
        Deployment for more information on automatic recognition and
        deployment of web applications. If not specified the default ofconf/<engine_name>/<host_name>will be used. |  | createDirs | If set to true, Tomcat will attempt to create the directories defined
        by the  attributes appBaseandxmlBaseduring
        the startup phase. The default value istrue. If set to
        true, and directory creation fails, an error message will be printed out
        but will not halt the startup sequence. |  | autoDeploy | This flag value indicates if Tomcat should check periodically for new
        or updated web applications while Tomcat is running. If true, Tomcat
        periodically checks the appBaseandxmlBasedirectories and deploys any new web applications or context XML
        descriptors found. Updated web applications or context XML descriptors
        will trigger a reload of the web application. The flag's value defaults
        to true.  See
        Automatic Application
        Deployment for more information. |  | backgroundProcessorDelay | This value represents the delay in seconds between the
        invocation of the backgroundProcess method on this host and
        its child containers, including all contexts.
        Child containers will not be invoked if their delay value is not
        negative (which would mean they are using their own processing
        thread). Setting this to a positive value will cause
        a thread to be spawn. After waiting the specified amount of time,
        the thread will invoke the backgroundProcess method on this host
        and all its child containers. A host will use background processing to
        perform live web application deployment related tasks. If not
        specified, the default value for this attribute is -1, which means
        the host will rely on the background processing thread of its parent
        engine. |  | className | Java class name of the implementation to use.  This class must
        implement the org.apache.catalina.Hostinterface.
        If not specified, the standard value (defined below) will be used. |  | deployIgnore | A regular expression defining paths to ignore when
        autoDeployanddeployOnStartupare set. This
        allows you to keep your configuration in a version control system, for
        example, and not deploy a .svn or CVS folder that happens to be in theappBase. This regular expression is relative to appBase. It is
        also anchored, meaning the match is performed against the
        entire file/directory name. So,foomatches only a file or
        directory namedfoobut notfoo.war,foobar, ormyfooapp. To match anything with
        "foo", you could use.*foo.*. See Automatic Application
        Deployment for more information. |  | deployOnStartup | This flag value indicates if web applications from this host should
        be automatically deployed when Tomcat starts. The flag's value defaults
        to true.  See
        Automatic Application
        Deployment for more information. |  | name | Usually the network name of this virtual host, as registered in your
        Domain Name Service server. Regardless of the case used to
        specify the host name, Tomcat will convert it to lower case internally.
        One of the Hosts nested within an Engine MUST
        have a name that matches the defaultHostsetting for that
        Engine.  See Host Name Aliases for
        information on how to assign more than one network name to the same
        virtual host. |  | startStopThreads | The number of threads this Host will use to start
        child Context elements in parallel. The same
        thread pool will be used to deploy new
        Contexts if automatic deployment is being
        used. The special value of 0 will result in the value of
        Runtime.getRuntime().availableProcessors()being used.
        Negative values will result inRuntime.getRuntime().availableProcessors() + valuebeing
        used unless this is less than 1 in which case 1 thread will be used. If
        not specified, the default value of 1 will be used. |  | undeployOldVersions | This flag determines if Tomcat, as part of the auto deployment
        process, will check for old, unused versions of web applications
        deployed using parallel deployment and, if any are found, remove them.
        This flag only applies if autoDeployis true. If not
        specified the default value of false will be used. | 
 | 
 | Standard Implementation |  | 
    The standard implementation of Host is
    org.apache.catalina.core.StandardHost.
    It supports the following additional attributes (in addition to the
    common attributes listed above): | Attribute | Description | 
|---|
 | copyXML | Set to trueif you want a context XML descriptor
        embedded inside the application (located at/META-INF/context.xml) to be copied toxmlBasewhen the application is deployed. On subsequent starts, the copied
        context XML descriptor will be used in preference to any context XML
        descriptor embedded inside the application even if the descriptor
        embedded inside the application is more recent. The flag's value
        defaults tofalse.  Note if deployXML
        isfalse, this attribute will have no effect. |  | deployXML | Set to falseif you want to disable parsing the context
        XML descriptor embedded inside the application (located at/META-INF/context.xml). Security conscious environments
        should set this tofalseto prevent applications from
        interacting with the container's configuration. The  administrator will
        then be responsible for providing an external context configuration
        file, and putting it in the location defined by the
        xmlBase attribute. If this flag isfalse,
        a descriptor is located at/META-INF/context.xmland no
        descriptor is present in xmlBase then the context will
        fail to start in case the descriptor contains necessary configuration
        for secure deployment (such as a RemoteAddrValve) which should not be
        ignored. The flag's value defaults totrueunless a
        security manager is enabled when the default isfalse. |  | errorReportValveClass | Java class name of the error reporting valve which will be used
        by this Host. The responsibility of this valve is to output error
        reports. Setting this property allows to customize the look of the
        error pages which will be generated by Tomcat. This class must
        implement the
        org.apache.catalina.Valveinterface. If none is specified,
        the valueorg.apache.catalina.valves.ErrorReportValvewill be used by default. |  | unpackWARs | Set to trueif you want web applications that are
        placed in theappBasedirectory as web application
        archive (WAR) files to be unpacked into a corresponding disk directory
        structure,falseto run such web applications directly
        from a WAR file. WAR files located outside of the Host's
        appBase will not be expanded. See
        Automatic Application
        Deployment for more information. |  | workDir | Pathname to a scratch directory to be used by applications for
        this Host. Each application will have its own sub directory with
        temporary read-write use.  Configuring a Context workDir will override
        use of the Host workDir configuration.  This directory will be made
        visible to servlets in the web application by a servlet context
        attribute (of type java.io.File) namedjavax.servlet.context.tempdiras described in the
        Servlet Specification.  If not specified, a suitable directory
        underneath$CATALINA_BASE/workwill be provided. | 
 | 
 | 
 | Nested Components |  | 
  You can nest one or more Context elements
  inside this Host element, each representing a different web
  application associated with this virtual host. You can nest at most one instance of the following utility components
  by nesting a corresponding element inside your Host
  element: 
  Realm -
      Configure a realm that will allow its
      database of users, and their associated roles, to be shared across all
      Contexts nested inside this Host (unless
      overridden by a Realm configuration
      at a lower level). | 
 | Special Features |  | 
  | Logging |  | 
    A host is associated with the
       org.apache.catalina.core.ContainerBase.[engine_name].[host_name]log category.  Note that the brackets are part of the name,
       don't omit them. | 
 | Automatic Application Deployment |  | 
    If you are using the standard Host implementation with
    default settings then applications in the appBase or with context
    files in the configBase are automatically deployed when Tomcat
    starts (the deployOnStartupproperty defaults totrue) and reloaded or redeployed (as appropriate) when a change
    is detected while Tomcat is running (theautoDeployattribute
    also defaults totrue). deployOnStartupandautoDeploytrigger
    execution of exactly the same code so the behaviour is very similar.
    However, there is one key difference. When Tomcat starts it has no knowledge
    of which files are the same, which have been changed and which are new. It
    therefore treats all files as new. While Tomcat is running, it can
    differentiate between unchanged, modified and new files. This leads to some
    differences in behaviour between files being modified while Tomcat is
    running and files being modified while Tomcat is stopped.
 When you use automatic deployment, related files (a web application may
    have a context.xml file, a WAR and a directory) that exist in the
    Host's appBase and/or configBase
    must conform to the expected naming
    convention. In short, this means files for the same web application must
    share the same base name. The automatic deployment process identifies new and/or modified web
    applications using the following search order: 
      Web applications with a context.xml file located in the Host's
      configBase.Web applications with a WAR file located in the Host's
      appBase that have not already been identified during the scan for
      context.xml files.Web applications with a directory located in the Host's
      appBase that have not already been identified during the scans
      for context.xml and/or WAR files. When autoDeployis true, the automatic
    deployment process will monitor the deployed web applications for changes.
    Depending on exactly what changes, the web application will either be
    re-deployed or reloaded. Re-deployment involves the creation of a new web
    application and, if using the standard session manager, user sessions will
    not be retained. Reloading uses the existing web application but re-parses
    the web.xml and reloads any classes. If using the standard session manager,
    user sessions will be persisted. Users may add to the files that the automatic deployment process monitors
    for reloading (i.e. any change to one of these files triggers a reload of
    the web application) by adding a WatchedResources element to the
    context.xml file. See the
    Context documentation for
    further details. When using automatic deployment, the docBasedefined by
    an XML Context file should be outside of theappBasedirectory. If this is not the case, difficulties
    may be experienced deploying the web application or the application may
    be deployed twice. ThedeployIgnoreattribute can be used
    to avoid this situation. Note that if you are defining contexts explicitly in server.xml, you
    should probably turn off automatic application deployment or specify
    deployIgnorecarefully. Otherwise, the web applications
    will each be deployed twice, and that may cause problems for the
    applications. There are many possible combinations of settings, new files, changed
    files and deleted files. A separate page describes the
    expected behaviour of the automatic
    deployment process in many of these scenarios. | 
 | Single Sign On |  | 
    In many environments, but particularly in portal environments, it
    is desireable to have a user challenged to authenticate themselves only
    once over a set of web applications deployed on a particular virtual
    host.  This can be accomplished by nesting an element like this inside
    the Host element for this virtual host: |  |  |  |  |  | 
<Host name="localhost" ...>
  ...
  <Valve className="org.apache.catalina.authenticator.SingleSignOn"/>
  ...
</Host>
 |  |  |  |  |  | 
The Single Sign On facility operates according to the following rules:
     
    All web applications configured for this virtual host must share the
        same Realm.  In practice, that means you can
        nest the Realm element inside this Host element (or the surrounding
        Engine element), but not inside a
        Context element for one of the involved
        web applications.As long as the user accesses only unprotected resources in any of the
        web applications on this virtual host, they will not be challenged
        to authenticate themselves.As soon as the user accesses a protected resource in
        any web application associated with this virtual
        host, the user will be challenged to authenticate himself or herself,
        using the login method defined for the web application currently
        being accessed.Once authenticated, the roles associated with this user will be
        utilized for access control decisions across all
        of the associated web applications, without challenging the user
        to authenticate themselves to each application individually.As soon as the user logs out of one web application (for example,
        by invalidating the corresponding session if form
        based login is used), the user's sessions in all
        web applications will be invalidated.  Any subsequent attempt to
        access a protected resource in any application will require the
        user to authenticate himself or herself again.The Single Sign On feature utilizes HTTP cookies to transmit a token
        that associates each request with the saved user identity, so it can
        only be utilized in client environments that support cookies. | 
 | 
 |