How Tomcat works

Source: Internet
Author: User

First, Apache-tomcat way:

Configuration file: Server.xml

Main Configuration items:

1. Server:

<port= "8005"  shutdown= "shutdown"></  Server>

Specify port 8005 to listen for requests to shut down Tomcat.

2, Connector: A total of two, define the connection between the client and the server. After the client initiates the request, it is forwarded to the engine for processing, and then the response is returned to the client.

The first listener 80 port (if only Tomcat, no Apache, here is listening to 8080 ports), directly receive requests from the client browser. If SSL (HTTPS) is requested, Port 8443 is used.

<port= "  protocol"= "http/1.1"               connectiontimeout  = "20000"               redirectport= "8443"/>

The second listens on Port 8009, receiving HTTP requests forwarded through other webserver (such as Apache).

<port= "8009"  protocol= "ajp/1.3"  redirectport= " 8443 "/>

3. Engine: Define Virtual Host

The host defines the virtual hostname and AppBase defines the application storage directory.

<name= "localhost"  appBase= "WebApps"             Unpackwars= "true"  autodeploy= "true">

Multiple hosts can be defined in the engine, and when the engine receives an HTTP request, it is matched to a virtual host, which is processed by the virtual host. If there is no match to a virtual host, the request is given to the default set of virtual hosts for processing.

When configured above, for example the application directory is: Webapps/hello/index ..., the access URL is Localhost/hello.

Second, the process of APACHE-TOMCAT processing HTTP requests:

1, the client directly requests 80/8080 port (or by 8009 port to receive the request forwarded by other webserver such as Apache), connector receives the client request.

2, connector the HTTP request to the engine.

3, the engine receives the request, matches to the corresponding host, the request is handed over to the host processing.

4. Host handles the request and returns the result on the original path.

5, connector received the processing results, returned to the client or other webserver.

How Tomcat works

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.