随笔 - 26, 文章 - 0, 评论 - 2, 引用 - 0
数据加载中……

Tc Config

Tomcat 启动过程分析:

 IE 地址栏中敲 :
http://localhost:8080/wsota/
wsota_index.jsp

1 请求被发送到本机端口8080 ,被在哪里监听的 Coyote HTTP/1.1 Connector 获得

2 Connector 把该请求交给 它所在的Service 中的 Engine 引擎去处理

3 Engine获得请求 localhost/wstoa/wstoa_index.jsp 匹配它所拥有的所有虚拟主机Host

4 Engine 匹配到名字为localhost 的Host (即使匹配不到也把请求交给该Host处理,因为该Host被定义为 该Engine的默认主机)

5 localhost Host 获得请求 /wstoa/wstoa_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 对象和 HttpServletRespose 对象 作为参数调用 JspServlet的 doGet或doPost方法。

10Context 把执行完了之后的 HttpServletRespose对象返回给HOST

11 Host 把HttpServletRespose 对象返回给 Engine

12 Engine把 HttpServletRespose对象返回给 Connector

13 Connector把 HttpServletRespose 对象 返回给 Browser


 

Tomcat Server的组成部分

1.1 - Server

A Server element represents the entire Catalina servlet container. (Singleton)

1.2 - Service

A Service element represents the combination of one or more Connector components that share a single Engine

Service是这样一个集合:它由一个或者多个Connector组成,以及一个Engine,负责处理所有Connector所获得的客户请求

1.3 - Connector

一个Connector将在某个指定端口上侦听客户请求,并将获得的请求交给Engine来处理,从Engine处获得回应并返回客户

TOMCAT有两个典型的Connector,一个直接侦听来自browser的http请求,一个侦听来自其它WebServer的请求

Coyote Http/1.1 Connector 在端口8080处侦听来自客户browser的http请求

Coyote JK2 Connector 在端口8009处侦听来自其它WebServer(Apache)的servlet/jsp代理请求

1.4 - Engine

The Engine element represents the entire request processing machinery associated with a particular Service

It receives and processes all requests from one or more Connectors

and returns the completed response to the Connector for ultimate transmission back to the client

Engine下可以配置多个虚拟主机Virtual Host,每个虚拟主机都有一个域名

当Engine获得一个请求时,它把该请求匹配到某个Host上,然后把该请求交给该Host来处理

Engine有一个默认虚拟主机,当请求无法匹配到任何一个Host上的时候,将交给该默认Host来处理

1.5 - Host

代表一个Virtual Host,虚拟主机,每个虚拟主机和某个网络域名Domain Name相匹配

每个虚拟主机下都可以部署(deploy)一个或者多个Web App,每个Web App对应于一个Context,有一个Context path

当Host获得一个请求时,将把该请求匹配到某个Context上,然后把该请求交给该Context来处理

匹配的方法是“最长匹配”,所以一个path==""的Context将成为该Host的默认Context

所有无法和其它Context的路径名匹配的请求都将最终和该默认Context匹配

1.6 - Context

一个Context对应于一个Web Application,一个Web Application由一个或者多个Servlet组成

Context在创建的时候将根据配置文件$CATALINA_HOME/conf/web.xml和$WEBAPP_HOME/WEB-INF/web.xml载入Servlet类

当Context获得请求时,将在自己的映射表(mapping table)中寻找相匹配的Servlet类

如果找到,则执行该类,获得请求的回应,并返回




Tomcat start console

2008-7-10 10:38:49 org.apache.coyote.http11.Http11BaseProtocol init

信息: Initializing Coyote HTTP/1.1 on http-8080

2008-7-10 10:38:49 org.apache.catalina.startup.Catalina load

信息: Initialization processed in 390 ms

2008-7-10 10:38:49 org.apache.catalina.core.StandardService start

信息: Starting service Catalina

2008-7-10 10:38:49 org.apache.catalina.core.StandardEngine start

信息: Starting Servlet Engine: Apache Tomcat/5.5.17

2008-7-10 10:38:49 org.apache.catalina.core.StandardHost start

信息: XML validation disabled

2008-7-10 10:38:50 org.apache.coyote.http11.Http11BaseProtocol start

信息: Starting Coyote HTTP/1.1 on http-8080

2008-7-10 10:38:50 org.apache.catalina.storeconfig.StoreLoader load

信息: Find registry server-registry.xml at classpath resource

2008-7-10 10:38:50 org.apache.catalina.startup.Catalina start

信息: Server startup in 750 ms


Note: 
 在配置context.xml
 D:\Dev_tools\apache-tomcat-5.5.17\conf\Catalina\localhost
 example:
 <Context docBase="D:\Projects\zzesweb\web" path="/zzesweb"
         reloadable="true" antiResourceLocking="false" antiJARLocking="false">
     <Resource
      auth="Container"
      name="jdbc/zzesweb"   
// <c:set var="dataSource" value="jdbc/zzesweb" scope="page"/>  
// <sql:query dataSource="${dataSource}" var ="rs"  scope="page../">
// sql
// </sql:query>

      type="javax.sql.DataSource"
      password="*"
      driverClassName="com.mysql.jdbc.Driver"
      maxIdle="30"
      maxWait="5000"
      username="root"
      url="jdbc:mysql://localhost:13306/zzesweb?autoReconnect=true"
      maxActive="100"/>
</Context>

posted on 2008-08-01 09:46 Anderson 阅读(183) 评论(0)  编辑  收藏 所属分类: java


只有注册用户登录后才能发表评论。


网站导航: