Tomcat最首要的成果是提供Servlet/JSP容器,尽量它也可以作为独立的Java Web处事器,它在对静态资源(如HTML文件或图像文件)的处理赏罚速率,以及提供的Web处事器打点成果方面都不如其他专业的HTTP处事器,如IIS和Apache处事器。
因此在现实应用中,经常把Tomcat与其他HTTP处事器集成。对付不支持Servlet/JSP的HTTP处事器,可以通过Tomcat处事器来运行Servlet/JSP组件。
当Tomcat与其他HTTP处事器集成时,Tomcat处事器的事变模式凡是为历程外的Servlet容器,Tomcat处事器与其他HTTP处事器之间通过专门的插件来通讯。
Tomcat在server.xml中设置了两种毗连器。
相干观念

Web客户会见Tomcat处事器的两种方法
- HTTP Connector:拥有这个毗连器,Tomcat才气成为一个web处事器,但还可处理赏罚Servlet和jsp。
- AJP Connector:AJP毗连器可以通过AJP协媾和另一个web容器举办交互。
Connector的设置
对Connector的设置位于conf/server.xml文件中。
1. BIO HTTP/1.1 Connector设置
一个典范的设置如下:
- <!--
- Code highlighting produced by Actipro CodeHighlighter (freeware)
- http://www.CodeHighlighter.com/
- --> connectionTimeout=”20000” redirectPort=”8443”
其余一些重要属性如下:
- acceptCount : 接管毗连request的最大毗连数量,默认值是10
- address : 绑定IP地点,假如不绑定,默认将绑定任何IP地点
- allowTrace : 假如是true,将应承TRACE HTTP要领
- compressibleMimeTypes : 各个mimeType, 以逗号脱离,如text/html,text/xml
- compression : 假如带宽有限的话,可以用GZIP压缩
- connectionTimeout : 超时时刻,默以为60000ms (60s)
- maxKeepAliveRequest : 默认值是100
- maxThreads : 处理赏罚哀求的Connector的线程数量,默认值为200
假如是SSL设置,如下:
- <!--
- Code highlighting produced by Actipro CodeHighlighter (freeware)
- http://www.CodeHighlighter.com/
- -->maxThreads="150" scheme="https" secure="true"
- clientAuth="false" sslProtocol = "TLS"
- address="0.0.0.0"
- keystoreFile="E:/java/jonas-full-5.1.0-RC3/conf/keystore.jks"
- keystorePass="changeit" />
个中,keystoreFile为证书位置,keystorePass为证书暗码
2. NIO HTTP/1.1 Connector设置
- <!--
- Code highlighting produced by Actipro CodeHighlighter (freeware)
- http://www.CodeHighlighter.com/
- --><Connector port=”8080” protocol=”org.apache.coyote.http11.Http11NioProtocol”
- maxThreads=”150” connectionTimeout=”20000” redirectPort=”8443”
3. Native APR Connector设置
ARP是用C/C++写的,对静态资源(HTML,图片等)举办了优化。以是要下载当地库
tcnative-1.dll与openssl.exe,将其放在%tomcat%bin目次下。
在server.xml中要设置一个Listener:
- <!--
- Code highlighting produced by Actipro CodeHighlighter (freeware)
- http://www.CodeHighlighter.com/
- --><!--APR library loader. Documentation at /docs/apr.html -->
- <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
- <!-- 设置行使APR connector --》
- <Connector port=”8080” protocol=”org.apache.coyote.http11.Http11AprProtocol”
- maxThreads=”150” connectionTimeout=”20000” redirectPort=”8443”
(编辑:湖南网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|