From the Tomcat Source Analysis (ii), it is known that a user's request will go through n-link processing, and finally reached the developer wrote the servlet, to the servlet is HttpServletRequest and HttpServletResponse, So it can be thought that this way is nothing more than the original socket package into the servlet used in the HttpServletRequest and httpservletresponse, but each link to complete the packaging function and the part is not the same, the information flow as shown:
The class diagram for request and response is as follows:
Org.apache.coyote.Request and Org.apache.coyote.Response are used internally by Tomcat and are not available to developer calls, and the class is final type. The following is a sequence diagram of a complete request to see the machining process from socket to org.apache.catalina.connector.Request:
From the visible, request parsing and processing process is not done in a method, but the flow of information in the process of gradual analysis, different levels of the processor to parse different levels of information, in the parsing process at the same time to do some judgment and interception work, such as when the discovery is to access web-inf resources, The error is returned directly to the client and so on.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Tomcat Architecture in detail (iii) the entire process of request and response processing