View the Tomcat component structure from the Tomcat server. xml file

Source: Internet
Author: User
The basic structure of server. xml is as follows:

<Server> <br/> top-level class elements: it can contain multiple services <br/> <Service> <br/> top-level class elements: it can contain one Engine and multiple ctor ins. <Br/> <Connector/> <br/> Connector element: Communication Interface <br/> <Engine> <br/> container element: processes customer requests for specific Service components. It can contain multiple hosts <br/> <Host> <br/> container elements: Processes customer requests for specific VM components, it can contain multiple Context <br/> <Context> <br/> container class elements: process all customer requests for a specific Web application <br/> </Contrext> <br/> </Host> <br/> </Engine> <br/> </Service> <br/> </Server> 

The following describes the elements:


<Server>

Each <Server> can have multiple <services>, and <Service> corresponds to approximately one IP address, so Tomcat can manage multiple IP addresses at the same time, that is to say, it has the ability to establish a server cluster.

<Service>

Each primary color of <Service> consists of one or more ctor ins, and an Engine that processes customer requests from all Connector.

Simply put, <Service> corresponds to an IP address.

<Connector>

Each <Service> z can contain multiple ctor ins, and each Connector listens to one port of the IP address corresponding to <Service>. The default port is 8080, And the other commonly listened port is 8009, which is used to listen for Servlet/JSP proxy requests from other Web servers (Apache.


<Engine>

Each <Service> has only one <Engine>. <Engine> processes customer requests received by Connector. Simply put, an Engine corresponds to an IP address and an address composed of several port numbers.

These port numbers correspond to the port number listened by <Connector>.

<Host>

Host represents a virtual Host. Each virtual Host matches a domain name. One or more Web apps can be deployed under each virtual host.

The Web App corresponds to a Context.

<Context>

Each <Context> element corresponds to a Web Applcation (about a Web project), and each Web App consists of one or more servlets. (JSP is essentially a Servlet and will be converted to Servlet by Tomcat ). The Context will load the Servlet at creation according to the configuration file $ CATALINA_HOME/conf/web. xml and $ WEBAPP_HOME/WEB-INF/web. xml.


Summary:

 

  1. The IP address is different from the domain name. Multiple Domain names can be resolved to the same IP address.
  2. <Engine> corresponds to one IP address + multiple ports, and can have multiple <Host> (domain name ).
  3. <Host> corresponds to a Domain Name and can have multiple Context (project ).
  4. <Context> corresponds to a project (Web App ).
A Tomcat default server. xml file

<! -- Note: A "Server" is not itself a "Container", so you may not <br/> define subcomponents such as "Valves" at this level. <br/> Documentation at/docs/config/server.html <br/> --> <br/> <Server port = "8005" shutdown = "SHUTDOWN"> <br/> <! -- APR library loader. documentation at/docs/apr.html --> <br/> <Listener className = "org. apache. catalina. core. aprLifecycleListener "SSLEngine =" on "/> <br/> <! -- Initialize Jasper prior to webapps are loaded. documentation at/docs/jasper-howto.html --> <br/> <Listener className = "org. apache. catalina. core. jasperListener "/> <br/> <! -- JMX Support for the Tomcat server. documentation at/docs/non-existent.html --> <br/> <Listener className = "org. apache. catalina. mbeans. serverLifecycleListener "/> <br/> <Listener className =" org. apache. catalina. mbeans. globalResourcesLifecycleListener "/> <br/> <! -- Global JNDI resources <br/> Documentation at/docs/jndi-resources-howto.html <br/> --> <br/> <GlobalNamingResources> <br/> <! -- Editable user database that can also be used by <br/> UserDatabaseRealm to authenticate users <br/> --> <br/> <Resource name = "UserDatabase" auth = "Container" <br/> type = "org. apache. catalina. userDatabase "<br/> description =" User database that can be updated and saved "<br/> factory =" org. apache. catalina. users. memoryUserDatabaseFactory "<br/> pathname =" conf/tomcat-users.xml "/> <br/> </GlobalNamingR Esources> <br/> <! -- A "Service" is a collection of one or more "Connectors" that share <br/> a single "Container" Note: A "Service" is not itself a "Container ", <br/> so you may not define subcomponents such as "Valves" at this level. <br/> Documentation at/docs/config/service.html <br/> --> <br/> <Service name = "Catalina"> </p> <! -- The connectors can use a shared executor, you can define one or more named thread pools --> <br/> <! -- <Br/> <Executor name = "tomcatThreadPool" namePrefix = "catalina-exec-" <br/> maxThreads = "150" minSpareThreads = "4"/> <br/> --> </p> <! -- A "Connector" represents an endpoint by which requests are already ed <br/> and responses are returned. documentation at: <br/> Java HTTP Connector:/docs/config/http.html (blocking & non-blocking) <br/> Java AJP Connector: /docs/config/ajp.html <br/> APR (HTTP/AJP) Connector: /docs/apr.html <br/> Define a non-ssl http/1.1 Connector on port 8081 --> <br/> <Connector port = "80" protocol = "HTTP/1.1" <Br/> connectionTimeout = "20000" <br/> redirectPort = "8443"/> <br/> <! -- A "Connector" using the shared thread pool --> <br/> <! -- <Br/> <Connector executor = "tomcatThreadPool" <br/> port = "8080" protocol = "HTTP/1.1" <br/> connectionTimeout = "20000" <br/> redirectPort = "8443"/> <br/> --> <br/> <! -- Define a ssl http/1.1 Connector on port 8443 <br/> This connector uses the JSSE configuration, when using APR, the <br/> connector shocould be using the OpenSSL style configuration <br/> described in the APR documentation --> <br/> <! -- <Br/> <Connector port = "8443" protocol = "HTTP/1.1" SSLEnabled = "true" <br/> maxThreads = "150" scheme = "https" secure = "true" <br/> clientAuth = "false" sslProtocol = "TLS"/> <br/> --> <br/> <! -- Define an AJP 1.3 Connector on port 8009 --> <br/> <Connector port = "8009" protocol = "AJP/1.3" redirectPort = "8443"/> </p> <p> <! -- An Engine represents the entry point (within Catalina) that processes <br/> every request. the Engine implementation for Tomcat stand alone <br/> analyzes the HTTP headers encoded with the request, and passes them <br/> on to the appropriate Host (virtual host ). <br/> Documentation at/docs/config/engine.html --> <br/> <! -- You shoshould set jvmRoute to support load-balancing via AJP ie: <br/> <Engine name = "Standalone" defaultHost = "localhost" jvmRoute = "jvm1"> <br/> --> <br/> <Engine name = "Catalina" defaultHost = "localhost"> <br/> <! -- For clustering, please take a look at documentation at: <br/>/docs/cluster-howto.html (simple how to) <br/>/docs/config/cluster.html (reference documentation) --> <br/> <! -- <Br/> <Cluster className = "org. apache. catalina. ha. tcp. SimpleTcpCluster"/> <br/> --> <br/> <! -- The request dumper valve dumps useful debugging information about <br/> the request and response data stored Ed and sent by Tomcat. <br/> Documentation at:/docs/config/valve.html --> <br/> <! -- <Br/> <Valve className = "org. apache. catalina. valves. RequestDumperValve"/> <br/> --> <br/> <! -- This Realm uses the UserDatabase configured in the global JNDI <br/> resources under the key "UserDatabase ". any edits <br/> that are already med against this UserDatabase are immediately <br/> available for use by the Realm. --> <br/> <Realm className = "org. apache. catalina. realm. userDatabaseRealm "<br/> resourceName =" UserDatabase "/> <br/> <! -- Define the default virtual host <br/> Note: XML Schema validation will not work with Xerces 2.2. <br/> --> <br/> <Host name = "localhost" appBase = "webapps" <br/> unpackWARs = "true" autoDeploy = "true" <br/> xmlValidation = "false" xmlNamespaceAware = "false"> <br/> <! -- SingleSignOn valve, share authentication between web applications <br/> Documentation at:/docs/config/valve.html --> <br/> <! -- <Br/> <Valve className = "org. apache. catalina. authenticator. SingleSignOn"/> <br/> --> <br/> <! -- Access log processes all example. <br/> Documentation at:/docs/config/valve.html --> <br/> <! -- <Br/> <Valve className = "org. apache. catalina. valves. accessLogValve "directory =" logs "<br/> prefix =" localhost_access_log. "suffix = ". txt "pattern =" common "resolveHosts =" false "/> <br/> --> <br/> </Host> <br/> </Engine> <br/> </Service> <br/> </Server> <br/> 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.