Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2834198
  • 博文数量: 471
  • 博客积分: 7081
  • 博客等级: 少将
  • 技术积分: 5369
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-04 21:55
文章分类

全部博文(471)

文章存档

2014年(90)

2013年(69)

2012年(312)

分类: 系统运维

2014-02-19 11:47:41

Tomcat Server的结构图



  1. 该文件描述了如何启动Tomcat Server

  1. <Server>
  2.     <Listener />
  3.     <GlobaNamingResources>
  4.     </GlobaNamingResources
  5.     <Service>
  6.         <Connector />
  7.         <Engine>
  8.             <Logger />
  9.             <Realm />
  10.                <host>
  11.                    <Logger />
  12.                    <Context />
  13.                </host>
  14.         </Engine>
  15.     </Service>
  16. </Server>

Tomcat Server处理一个http请求的过程
假设来自客户的请求为:

1) 请求被发送到本机端口8080,被在那里侦听的Coyote HTTP/1.1 Connector获得
2) Connector把该请求交给它所在的Service的Engine来处理,并等待来自Engine的回应
3) Engine获得请求localhost/wsota/wsota_index.jsp,匹配它所拥有的所有虚拟主机Host
4) Engine匹配到名为localhost的Host(即使匹配不到也把请求交给该Host处理,因为该Host被定义为该Engine的默认主机)
5) localhost Host获得请求/wsota/wsota_index.jsp,匹配它所拥有的所有Context
6) Host匹配到路径为/wsota的Context(如果匹配不到就把该请求交给路径名为""的Context去处理)
7) path="/wsota"的Context获得请求/wsota_index.jsp,在它的mapping table中寻找对应的servlet
8) Context匹配到URL PATTERN为*.jsp的servlet,对应于JspServlet类
9) 构造HttpServletRequest对象和HttpServletResponse对象,作为参数调用JspServlet的doGet或doPost方法
10)Context把执行完了之后的HttpServletResponse对象返回给Host
11)Host把HttpServletResponse对象返回给Engine
12)Engine把HttpServletResponse对象返回给Connector
13)Connector把HttpServletResponse对象返回给客户browser


阅读(1338) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~