how
how
how
how tomcat
tomcat
tomcat
tomcat works
works
works
works
中文版
2011-5-26
曹旭东
II
I
目录
目录
...........................................................................................................................................................
I
简介
..........................................................................................................................................................
1
概览
..................................................................................................................................................
1
适合读者
.........................................................................................................................................
1
servlet 容器是如何工作的
...........................................................................................................
1
catalina 结构图
..............................................................................................................................
1
tomcat 的版本 4 和版本 5
..........................................................................................................
2
章节简介
........................................................................................................................................
2
第 1 章 一个简单的 Web 服务器
.....................................................................................................
3
1.1 The Hypertext Transfer Protocol ( HTTP )
.................................................................
3
1.2 HTTP Request
..................................................................................................................
3
1.3 HTTP Response
...............................................................................................................
4
1.4 Socket 类
.............................................................................................................................
4
1.5 ServerSocket 类
.................................................................................................................
5
1.6 应用举例
..............................................................................................................................
5
第 2 章 一个简单的 servlet 容器
.....................................................................................................
7
2.1 简述
.......................................................................................................................................
7
2.2 javax . servlet . Servlet 接口
...............................................................................................
7
2.3 Application 1
......................................................................................................................
7
2.3.1 HttpServer 1 类
.......................................................................................................
8
II
2.3.2 Request 类
............................................................................................................
8
2.3.3 Response 类
.........................................................................................................
9
2.3.4 StaticResourceProcessor 类
.............................................................................
9
2.3.5 ServletProcessor 1 类
..........................................................................................
9
2.4 Application 2
....................................................................................................................
9
第 3 章 连接器( Connector )
.......................................................................................................
11
3.1 概述
......................................................................................................................................
11
3.2 StringManager 类
.............................................................................................................
11
3.3 Application
........................................................................................................................
12
3.3.1 启动
........................................................................................................................
13
3.3.2 connector
.............................................................................................................
13
3.3.3 创建 HttpRequest 对象
......................................................................................
13
3.3.3.1 SocketInputStream 类
...........................................................................
14
3.3.3.2 解析请求行( request line )
...............................................................
14
3.3.3.3 解析请求头( request header )
.........................................................
14
3.3.3.4 解析 cookie
.............................................................................................
15
3.3.3.5 获取参数
..................................................................................................
16
3.3.3.6 创建 HttpResponse 对象
......................................................................
16
3.3.3.7 静态资源处理器和 servlet 处理器
.......................................................
17
第 4 章 tomcat 的默认连接器
........................................................................................................
18
4.1 简介
.....................................................................................................................................
18
4.2 HTTP 1.1 的新特性
...........................................................................................................
18
III
4.2.1 持久化连接
............................................................................................................
18
4.2.2 编码
.......................................................................................................................
18
4.2.3 状态码 100 的使用
.............................................................................................
19
4.3 Connector 接口
...............................................................................................................
19
4.4 HttpConnector 类
...........................................................................................................
20
4.4.1 创建 ServerSocket
.............................................................................................
20
4.4.2 维护 HttpProcessor 对象池
.............................................................................
20
4.4.3 提供 Http 请求服务
.............................................................................................
21
4.5 HttpProcessor 类
............................................................................................................
21
4.6 request 对象
....................................................................................................................
24
4.7 response 对象
.................................................................................................................
24
4.8 处理 request 对象
..........................................................................................................
25
4.8.1 解析连接
...............................................................................................................
28
4.8.2 解析 request
.......................................................................................................
28
4.8.3 解析请求头
..........................................................................................................
28
4.9 简单的 container 程序
...................................................................................................
30
第 5 章 container
.............................................................................................................................
31
5.1 Container 接口
..................................................................................................................
31
5.2 流水线( pipeline )任务
...............................................................................................
32
5.2.1 Pipeline
.................................................................................................................
34
5.2.2 Valve 接口
...........................................................................................................
35
5.2.3 ValveContext 接口
............................................................................................
35