设为首页 收藏本站
云服务器等爆品抢先购,低至4.2元/月
查看: 590|回复: 0

[经验分享] Tomcat深入学习笔记(一)

[复制链接]

尚未签到

发表于 2017-1-19 08:07:37 | 显示全部楼层 |阅读模式
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.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-330409-1-1.html 上篇帖子: eclipse3: add tomcat-plugin 下篇帖子: TOMCAT出错:java.lang.OutOfMemoryError
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表