您好,登录后才能下订单哦!
这篇“servlet和tomcat的知识点有哪些”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“servlet和tomcat的知识点有哪些”文章吧。
servlet是什么
为了能让web服务器与web应用这两个不同的软件系统协作,需要一套标准接口,servlet就是其中最主要的一个接口。
规定:
web服务器可以访问任意一个web应用中实现servlet接口的类。
web应用中用于被web服务器动态调用的程序代码位于servlet接口的实现类中。
sun公司(现在被oracle收购了……)制定了web应用于web服务器进行协作的一系列标准java接口(统称为java servlet api)。
sun公司还对web服务器发布及运行web应用的一些细节做了规约。sun公司把这一系列标准java接口和规约统称为servlet规范。
servlet是一种运行在服务器上的小插件。
servlet容器是什么
在servlet规范中,把能够发布和运行javaweb应用的web服务器称为servlet容器,他的最主要特称是动态执行javaweb应用中的servlet实现类中的程序代码。
tomcat是什么
tomcat是servlet容器,同时也是轻量级的web服务器。
apache server、microsoft iis、apache tomcat都是web服务器。
tomcat作为web服务器时,主要负责实现http传输等工作。
tomcat作为servlet容器时,主要负责解析request,生成servletrequest、servletresponse,将其传给相应的servlet(调用service( )方法),再将servlet的相应结果返回。
tomcat组成结构
server,代表整个servlet容器组件,是tomcat的顶层元素。其中可以包含一到多个service;
service,包含一个engine,以及一到多个connector;
connector,代表和客户端程序实际交互的组件,负责接收客户请求,以及向客户返回响应结果;
engine,处理同一个service中所有connector接收到的客户请求;
host,在engine中可以包含多个host,每个host定义了一个虚拟主机,它可以包含一个到多个web应用;
context,一个host中可以包含多个context,每个context代表了运行在虚拟主机上的单个web应用。
这些字段都在conf/server.xml中配置,下面是一段apache tomcat 6.0.36默认的server.xml:
<?xml version='1.0' encoding='utf-8'?> <!-- licensed to the apache software foundation (asf) under one or more contributor license agreements. see the notice file distributed with this work for additional information regarding copyright ownership. the asf licenses this file to you under the apache license, version 2.0 (the "license"); you may not use this file except in compliance with the license. you may obtain a copy of the license at http://www.apache.org/licenses/license-2.0 unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. see the license for the specific language governing permissions and limitations under the license. --> <!-- note: a "server" is not itself a "container", so you may not define subcomponents such as "valves" at this level. documentation at /docs/config/server.html --> <server port="8005" shutdown="shutdown"> <!--apr library loader. documentation at /docs/apr.html --> <listener classname="org.apache.catalina.core.aprlifecyclelistener" sslengine="on" /> <!--initialize jasper prior to webapps are loaded. documentation at /docs/jasper-howto.html --> <listener classname="org.apache.catalina.core.jasperlistener" /> <!-- prevent memory leaks due to use of particular java/javax apis--> <listener classname="org.apache.catalina.core.jrememoryleakpreventionlistener" /> <!-- jmx support for the tomcat server. documentation at /docs/non-existent.html --> <listener classname="org.apache.catalina.mbeans.serverlifecyclelistener" /> <listener classname="org.apache.catalina.mbeans.globalresourceslifecyclelistener" /> <!-- global jndi resources documentation at /docs/jndi-resources-howtohtml --> <globalnamingresources> <!-- editable user database that can also be used by userdatabaserealm to authenticate users --> <resource name="userdatabase" auth="container" type="org.apache.catalina.userdatabase" description="user database that can be updated and saved" factory="org.apache.catalina.users.memoryuserdatabasefactory" pathname="conf/tomcat-users.xml" /> </globalnamingresources> <!-- a "service" is a collection of one or more "connectors" that share a single "container" note: a "service" is not itself a "container", so you may not define subcomponents such as "valves" at this level. documentation at /docs/config/service.html --> <service name="catalina"> <!--the connectors can use a shared executor, you can define one or more named thread pools--> <!-- <executor name="tomcatthreadpool" nameprefix="catalina-exec-" maxthreads="150" minsparethreads="4"/> --> <!-- a "connector" represents an endpoint by which requests are received and responses are returned. documentation at : java http connector: /docs/config/http.html (blocking & non-blocking) java ajp connector: /docs/config/ajp.html apr (http/ajp) connector: /docs/apr.html define a non-ssl http/1 connector on port 8080 --> <connector port="8080" protocol="http/1.1" connectiontimeout="20000" redirectport="8443" /> <!-- a "connector" using the shared thread pool--> <!-- <connector executor="tomcatthreadpool" port="8080" protocol="http/1.1" connectiontimeout="20000" redirectport="8443" /> --> <!-- define a ssl http/1.1 connector on port 8443 this connector uses the jsse configuration, when using apr, the connector should be using the openssl style configuration described in the apr documentation --> <!-- <connector port="8443" protocol="http/1" sslenabled="true" maxthreads="150" scheme="https" secure="true" clientauth="false" sslprotocol="tls" /> --> <!-- define an ajp 1.3 connector on port 8009 --> <connector port="8009" protocol="ajp/1.3" redirectport="8443" /> <!-- an engine represents the entry point (within catalina) that processes every request the engine implementation for tomcat stand alone analyzes the http headers included with the request, and passes them on to the appropriate host (virtual host). documentation at /docs/config/engine.html --> <!-- you should set jvmroute to support load-balancing via ajp ie : <engine name="catalina" defaulthost="localhost" jvmroute="jvm1"> --> <engine name="catalina" defaulthost="localhost"> <!--for clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <cluster classname="org.apache.catalina.ha.tcp.simpletcpcluster"/> --> <!-- the request dumper valve dumps useful debugging information about the request and response data received and sent by tomcat. documentation at: /docs/config/valve.html --> <!-- <valve classname="org.apache.catalina.valves.requestdumpervalve"/> --> <!-- this realm uses the userdatabase configured in the global jndi resources under the key "userdatabase". any edits that are performed against this userdatabase are immediately available for use by the realm. --> <realm classname="org.apache.catalina.realm.userdatabaserealm" resourcename="userdatabase"/> <!-- define the default virtual host note: xml schema validation will not work with xerces 2.2. --> <host name="localhost" appbase="webapps" unpackwars="true" autodeploy="true" xmlvalidation="false" xmlnamespaceaware="false"> <!-- singlesignon valve, share authentication between web applications documentation at: /docs/config/valve.html --> <!-- <valve classname="org.apache.catalina.authenticator.singlesignon" /> --> <!-- access log processes all example. documentation at: /docs/config/valve.html --> <!-- <valve classname="org.apache.catalina.valves.accesslogvalve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolvehosts="false"/> --> </host> </engine> </service> </server>
以上就是关于“servlet和tomcat的知识点有哪些”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。