[서버][링크] Tomcat이 동작하는 원리
톰캣이 내부적으로 어떻게 동작하는지 궁금해서 찾아봤습니다.
정리된 글이 아니고 공부를 위해 관련된 글들 링크를 남깁니다.
조금 긴 설명이지만 영어로 정리된 글이 있습니다.
www.mulesoft.com/tcat/tomcat-servlet
한글로 된 자료도 있네요 ㅎㅎ
blog.naver.com/dct0629/221637905528
www.programmersought.com/article/12015084904/
phenomenon:
A tomcat can have multiple web applications, when it starts, it will start a jvm process. Multiple tomcats will start multiple jvm processes.
the reason:
Tomcat is a JSP/Servlet container. As a servlet container, it has three working modes:
independent servlet container,
in-process servlet container,
and out-of-process servlet container.
Tomcat Server processes an HTTP request:
Description:
1. The user clicks on the content of the web page, and the request is sent to port 8080 of the local machine, which is obtained by the Coyote HTTP/1.1 Connector that is monitoring there.
2. The Connector passes the request to the Engine of the Service where it is located for processing, and waits for the Engine's response.
3. Engine gets the request localhost/test/index.jsp, matching all virtual hosts Host.
4. The Engine matches the Host named localhost (even if it fails to match, the request will be handed over to the Host, because the Host is defined as the default host of the Engine), and the Host named localhost gets the request /test/index.jsp , To match all the Context it has. Host matches the Context whose path is /test (if it fails to match, hand the request to the Context whose path name is "" for processing).
5. Context with path="/test" obtains the request /index.jsp, and finds the corresponding Servlet in its mapping table. Context matches the Servlet whose URL PATTERN is *.jsp, which corresponds to the JspServlet class.
6. Construct HttpServletRequest object and HttpServletResponse object, call doGet() or doPost() of JspServlet as parameters. Perform business logic, data storage and other programs.
7. Context returns the HttpServletResponse object after execution to Host.
8. Host returns the HttpServletResponse object to Engine.
9. The Engine returns the HttpServletResponse object to the Connector.
10. The Connector returns the HttpServletResponse object to the client Browser.
www.mulesoft.com/tcat/tomcat-jvm
Tomcat이 JVM 위에서 동작한다고 하네요.
댓글 영역