`

Tomcat深入学习笔记(一)

阅读更多
tomcat-docs/appdev/deployment.html:

1, $CATALINA_HOME/common/lib or $CATALINA_HOME/shared/lib
        1.1 both to web applications and internal Tomcat code. This is a good place to put JDBC drivers that are required for both your application and internal Tomcat use(such as for a JDBCRealm,what is JDBCRealm?).
        1.2 to all web applications, but not to internal Tomcat code.
2, However, if you have configured Tomcat 5 for multiple instances by setting a CATALINA_BASE directory, you should use $CATALINA_BASE instead of $CATALINA_HOME for each of these references.
这里的$CATALINA_BASE有什么用?我自己机子上是装了好几个Tomcat(当然是以copy-paste的方式装的),也没有用过这个$CATALINA_BASE,难道说可以对一个安装好的Tomcat进行多次配置么?从而表现出有好多个Tomcat一样.就像现在Windows一样,虽然只有一个系统装在机子上,但可以通过Admin配置的方式把让很多不同的用户使用,让用户有他自己的个性化配置.

3,/WEB-INF/web.xml:
        3.1 defines everything about your application that a server needs to know (except the context path, which is assigned by the system administrator when the application is deployed).一般情况下admin是不另设这个context path的,那这样Tomcat是不是就默认地采用war包的名字呢?
        3.2 tomcat-docs/appdev/web.xml.txt
            3.2.0 The complete syntax and semantics for the deployment descriptor is defined in Chapter 13 of the Servlet API Specification, version 2.3.看看ServletAPI Spec中对这个DD的描述.
            3.2.1 <display-name>My Web Application</display-name>,这个display-name是干啥的?据上面所说(except the context path)知与context path没什么关系,那这个display-name有什么用呢?是工程名字,虽然不是context path,就像"地名"与"站名"关系一样?
            3.2.2 <context-param> 与getServletContext().getInitParameter("name");这个不说还真忘了,虽说不是什么难点,也没多大实际的用处.
            3.2.3 HttpSession.getMaxInactiveInterval() 与 <session-config>
From a servlet or JSP page, you can modify
the timeout for a particular session dynamically by using
HttpSession.getMaxInactiveInterval().
            3.2.4 <servlet-mapping>
                有下面的mapping设置:
                    <servlet-mapping>
                            <servlet-name>controller</servlet-name>
                            <url-pattern>*.do</url-pattern>
                    </servlet-mapping>

                    <servlet-mapping>
                            <servlet-name>graph</servlet-name>
                            <url-pattern>/graph</url-pattern>
                    </servlet-mapping>

        文档中说:
            Thus, a request URI like:

http://localhost:8080/{contextpath}/graph

will be mapped to the "graph" servlet, while a request like:

http://localhost:8080/{contextpath}/saveCustomer.do

will be mapped to the "controller" servlet.

我的疑问是:1,http://localhost:8080/{contextpath}/graph/saveCustomer.do 这样的访问路径Tomcat会怎么来处理?当然作为Coder这样的访问路径应该是尽力避免的.
2, http://localhost:8080/{contextpath}/graph这个访问路径的处理.这样的设置自己用的很少,也见的不多.

4, Tomcat Context Descriptor : /META-INF/context.xml file
        4.1 defines Tomcat specific configuration options, such as loggers,data sources,session manager configuration and more.
这里说是"Tomcat specific",那别的Server就不能用了.
这些内容也正是这些天困绕我的地方.不过好像在项目中,这个context.xml文件并没有配置,而是以\conf文件夹下如下所示的几个文件来配置的:
cachemapping.properties, cmt.properties, cmt.xml, ehcache.xml,
log4j.xml, system.properties
        4.2 This XML file must contain one Context element, which will be considered as if it was the child of the Host element corresponding to the Host to which the The Tomcat configuration documentation contains information on the Context element.
这句话怎么理解?说这个Context element可以看作是Host的一个子element,那么也就是说Context是Tomcat对用户提供配置的一个接口,as if 被Host引用.
这里的Host又是什么?是Tomcat底层应用的一个配置文件么?一直没见过.有项目中会用到么?

5, Deployment With Tomcat 5
        5.1 Copy unpacked directory hierarchy into a subdirectory in directory $CATALINA_HOME/webapps/.
        5.1.1 Tomcat will assign a context path to your application based on the subdirectory name you choose.
        5.1.2 We will use this technique in the build.xml file that we construct,
这里的build.xml是什么?
对了,这句话的意思可能是说"在接下来的实例中,我们将在Ant的脚本build.xml中采用这个deploy方式"
        5.1.3 Be sure to restart Tomcat after installing or updating your application.
        5.2 Copy the web application archive file into directory $CATALINA_HOME/webapps/.
                  5.2.1 NOTE - If you use this approach, and wish to update your application later, you must both replace the web application archive file AND delete the expanded directory that Tomcat created, and then restart Tomcat, in order to reflect your changes.
        5.3 Use the Tomcat 5 "Manager" web application to deploy and undeploy web applications.
                    5.3.1 a web application,allows you to deploy and undeploy applications on a running tomcat server without restarting it.
        5.4 Use "Manager" Ant Tasks In Your Build Script.
5.4.1 These tasks are used in the Tomcat deployer.      
        5.5 Use the Tomcat Deployer
                5.5.1 ..............
Note that other containers are NOT required to accept an unpacked directory structure (as Tomcat does), or to provide mechanisms for shared library files, but these features are commonly available.

 

4
2
分享到:
评论
1 楼 galaxystar 2008-03-09  
不错,如果 tomcat 跑在 linux 上就能完全发挥了。
推荐一个 Linux 发行版 - gentoo。
这里是 javaeye 圈子 http://gentoo.group.iteye.com

相关推荐

Global site tag (gtag.js) - Google Analytics