Tomcat简介
2019-09-23
[Tomcat源码](https://github.com/apache/tomcat)
阐述的内容
- Tomcat结构图
- Tomcat启动过程
- Tomcat请求处理过程
1. Tomcat结构
- Service
- Connector
- Container
- Engine
- Host
- Context
- Wrapper: 对应一个Servlet Class
- Context
- Host
- Engine
- Container
- Connector
2. Tomcat启动过程
3. Tomcat请求处理过程
- 本机端口获取数据, Connector获取
- Connector: 监听端口的TCP连接请求
- 创建Request和Response
- 产生一个线程把请求传递给Container.Engine
- Container的Engine获取请求, 交给Host
- Host获取请求, 交给Context
- Context获取请求, 匹配Servlet,交给Servlet
- 构造HttpServletRequest, HttpServletResponse
- Context返回HttpServletResponse给Host
- Context获取请求, 匹配Servlet,交给Servlet
- Host返回HttpServletResponse给Engine
- Host获取请求, 交给Context
- Engine返回HttpServletResponse给Connector
- Container的Engine获取请求, 交给Host
- Connector返回HttpServletResponse给Browser
- Connector: 监听端口的TCP连接请求