Tomcat-3

本文详细介绍了HTTPS协议的工作原理,Tomcat请求处理流程,以及三种常见的Tomcat部署方式(war包、server.xml配置和独立部署文件)。同时涵盖了Eclipse中Tomcat配置和web监听器的角色,包括ServletContextListener等关键概念。

目录

1. https协议介绍
2. tomcat请求处理
3. tomcat的部署方式录
3.1 在部署目录部署war包
3.2 通过server.xml部署
3.3 独立部署文件
4. eclipse中的tomcat配置
5. 关于web监听器
1. https协议介绍
HTTPS协议在通信时,首先会采用公钥加密的方式,把密钥进行公钥加密,然后传输给服务器,服务器使用私钥解密出密钥后,客户端和服务器即可建立起安全的访问通道。在接下来的通信就会采用速度更快的共享密钥加密的方式进行数据传输。这样HTTPS协议就既拥有公钥加密的安全性,同时也拥有了通用加密的高速的两个优点。

对称加密:加密和解密用同一个密钥,客户端对数据加密,服务端解密拿到数据
非对称加密:使用公钥和私钥,公钥加密的内容只能私钥解开,私钥加密的内容所有公钥都能解开;私钥只保存在服务器端,公钥可以发送给所有客户端,可以保证客户端通过公钥加密的内容中间人无法破解

2. tomcat请求处理

 

 

3. tomcat的部署方式录

 

3.1 在部署目录部署war包
这种方式部署最简单,也是在最常用的一种方式,如:在tomcat的server.xml文件中有如下配置:

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
   ......
</Host>


此文件说明虚拟服务器localhost,使用webapps作为部署目录,只要将war包部署在该目录中即可完成部署,
• unpackWARs参数表示,tomcat会对部署在webapps目录中的war文件自动解压,如果为false,则不执行自定解压,但会影响程序的运行效率,
• autoDeploy表示自动部署,即热部署

3.2 通过server.xml部署

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
		
		<!-- 部署web项目 -->
		<Context path="/webdemo" docBase="D:\work\eclipsews\webdemo\WebContent"></Context>

      </Host>


这种方式需要修改server.xml,不建议使用

3.3 独立部署文件

• 首先来到 \conf\Catalina 目录,
• 然后再依据虚拟服务器名称一致的方式,创建一个目录(如:localhost)
• 创建一个xml文件,完成项目部署,文件名与部署项目的上下文名称对应,例如:webdemo.xml,内容如下:

<Context path="/webdemo" docBase="D:\work\eclipsews\webdemo\WebContent"></Context>

4. eclipse中的tomcat配置

(1) eclipse 中 tomcat的基本配置
(2) eclipse 中 tomcat的运行基本原理
(3) 常见问题及处理

 

 

 

第一行把Tomcat的目录改了,改到eclipse自定义的一个临时目录去了
第二行是说我启动时用的哪个服务器
第三行是项目部署地

5. 关于web监听器

web监听器的类型:
• ServletContextListener 监听Context对象的创建与销毁,Context即web应用
• ServletContextAttributeListener 监听在Context中发生增加,更新,删除对象的事件
• HttpSessionListener 监听session对象的创建与销毁
• HttpSessionAttributeListener 监听在session中发生的增加,更新,删除对象的事件
• ServletRequestListener 监听request对象的创建
• ServletRequestAttributeListener 监听在session中发生的增加,更新,删除对象的事件
以上6中监听器,需要在web.xml中进行配置,除以上6种监听器还有下面两种监听器:
• HttpSessionBindingListener 当对象被放入session里执行valueBound,被移除时执行valueUnbound
• HttpSessionActivationListener 服务关闭时可以使用该监听器将session数据持久化到磁盘,服务重启会session数据会从磁盘重新加载,对应的使用示例可以参考tomcat01
以上两个监听器主要用于对session内对象的监听, 与上面的6中监听器不同的是,这两种监听器虽然需要实现对应的Listener接口,但不用在web.xml中配置。
 

└─# docker-compose logs tomcat-1 | # tomcat-1 | # A fatal error has been detected by the Java Runtime Environment: tomcat-1 | # tomcat-1 | # SIGSEGV (0xb) at pc=0x00007efece88d532, pid=1, tid=139632864130816 tomcat-1 | # tomcat-1 | # JRE version: OpenJDK Runtime Environment (7.0_121) (build 1.7.0_121-b00) tomcat-1 | # Java VM: OpenJDK 64-Bit Server VM (24.121-b00 mixed mode linux-amd64 compressed oops) tomcat-1 | # Derivative: IcedTea 2.6.8 tomcat-1 | # Distribution: Debian GNU/Linux 8.7 (jessie), package 7u121-2.6.8-2~deb8u1 tomcat-1 | # Problematic frame: tomcat-1 | # C [libc.so.6+0x36532] abort+0x232 tomcat-1 | # tomcat-1 | # Core dump written. Default location: /usr/local/tomcat/core or core.1 tomcat-1 | # tomcat-1 | # An error report file with more information is saved as: tomcat-1 | # /usr/local/tomcat/hs_err_pid1.log tomcat-1 | # tomcat-1 | # If you would like to submit a bug report, please include tomcat-1 | # instructions on how to reproduce the bug and visit: tomcat-1 | # http://icedtea.classpath.org/bugzilla tomcat-1 | # The crash happened outside the Java Virtual Machine in native code. tomcat-1 | # See problematic frame for where to report the bug. tomcat-1 | # tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1 | tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1 | tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1 | tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1 | tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1 | tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1 | tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1 | tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1 | tomcat-1 | tomcat-1 | [error occurred during error reporting , id 0xb] tomcat-1
09-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值