Tomcat HTTP protocol and AJP protocol

Source: Internet
Author: User

AJP13 is a directional packet protocol. For performance reasons, use binary format to transfer readability text. The Web server is connected through a TCP connection and a servlet container. To reduce the cost of the process to generate a socket, the Web server and the servlet container try to maintain a persistent TCP connection and reuse a connection for multiple request/reply loops. Once the connection is assigned to a specific request, it is not allocated before the request processing loop ends. In other words, on the connection, the request is not plural. This is the connection at both ends of the coding made easy, although this leads to a lot of connections at a time.

Once the Web server has opened a connection to the servlet container, the connection is in the following state:

Idle

There are no requests processed on this connection.

has been assigned

The connection is processing a specific request.

Once a connection is assigned to a specific request, the basic request information sent on the connection is highly compressed. At this point, the servlet container is probably ready to start processing the request, and when it is processed, it can send back the following information to the Web server:

Send_headers

Sends a set of headers to the browser.

Send_body_chunk

Sends a piece of body data to the browser.

Get_body_chunk

It is necessary to obtain the next data from the request if the packet length of the requested content is very large or the length is indeterminate. For example, uploading a file. Note that this is not associated with the block transport of HTTP.

End_response

Ends the request processing loop.

The tomcat server connects to the client through the Connector Connector component, the connector component is responsible for receiving the customer's request, and the results of the Tomcat server's response are sent to the customer. By default, Tomcat configures two types of connectors in Server.xml:

  

  

  

Maxthreads= "150"

Minsparethreads= "25"

maxsparethreads= "75"

Enablelookups= "false"

Redirectport= "8443"

acceptcount= "100"

debug= "0"

connectiontimeout= "20000"

Disableuploadtimeout= "true"/>

  

  

  

Enablelookups= "false"

Redirectport= "8443" debug= "0"

Protocol= "ajp/1.3"/>

The first connector listens on port 8080 and is responsible for establishing an HTTP connection. This connector is used when accessing a web App for a tomcat server through a browser.

The second connector listens on port 8009 and is responsible for establishing connections to other HTTP servers. When you integrate Tomcat with other HTTP servers, you need to use this connector.

The Web client accesses the JSP component on the Tomcat server in two ways, as shown in 22-1.

   

Figure 22-1 Two ways a Web client accesses a JSP component on a tomcat server

  

In Figure 22-1,

Web Client 1 directly accesses the JSP component on the Tomcat server, and the URL he accesses is http://localhost:8080/index.jsp.

Web Client 2 accesses the JSP components on the Tomcat server through an HTTP server. Assuming that the HTTP server uses the HTTP port as the default port of 80, Web Client 2 accesses the URL http://localhost:80/index.jsp or http://localhost/index.jsp.

Source: http://blog.chinaunix.net/uid-20662363-id-3012760.html

Tomcat HTTP protocol and AJP protocol

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.