Tomcat HTTP protocol and AJP protocol

Source: Internet
Author: User
Tags tomcat server

AJP13 is the directional package protocol. For performance reasons, the binary format is used to transmit readability text. The Web server is connected through a TCP connection and a servlet container. To reduce the cost of process generation sockets, the Web server and the servlet container try to maintain a persistent TCP connection and reuse a connection for multiple request/reply loops. Once a connection is assigned to a specific request, it is not allocated until the request processing loop has ended. In other words, the request is not multiple on the connection. This is the connection between the two ends of the coding becomes easier, 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
Send a piece of principal data to the browser.
Get_body_chunk
Getting the next data from a request if the packet length of the request content is very large or uncertain, it is necessary if the package is not fully transmitted. such as uploading files. Note that this is not associated with the HTTP block transfer.
End_response
Ends the request processing loop.

The Tomcat server establishes a connection to the client through the Connector Connector component, the connector component is responsible for receiving the customer's request, and sends the results of the Tomcat server's response to the customer. By default, Tomcat has two connectors configured in Server.xml.

<!--Define a non-ssl Coyote http/1.1
Connector on port 8080--> <connector port=
"8080"
Maxthre "Ads="
minsparethreads= "maxsparethreads=" enablelookups= "
false"
redirectport= "8443" c7/> acceptcount= "debug=" "0"
connectiontimeout= "20000"
disableuploadtimeout= "true"/>
& lt;! --Define a COYOTE/JK2 AJP 1.3 Connector on port 8009--> <connector port=
"8009"
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 Web applications from the Tomcat server through a browser.

The second connector listens on port 8009 and is responsible for establishing a connection with other HTTP servers. This connector is needed when you integrate Tomcat with other HTTP servers. Two ways for Web clients to access JSP components on a Tomcat server are shown in Figure 22-1.


Figure 22-1 Web customer access to JSP components on a tomcat server in two ways

In Figure 22-1, the Web customer 1 directly accesses the JSP component on the Tomcat server, and the URL he accesses is http://localhost:8080/index.jsp. Web Customer 2 accesses the JSP components on the Tomcat server through an HTTP server. Assuming the HTTP server uses the HTTP port as the default 80 port, then the Web Client 2 accesses the URL of http://localhost:80/index.jsp or http://localhost/index.jsp.

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

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.