您好,登錄后才能下訂單哦!
這篇“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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。