溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

servlet和tomcat的知識點有哪些

發(fā)布時間:2022-05-10 10:24:37 來源:億速云 閱讀:116 作者:zzz 欄目:大數(shù)據(jù)

這篇“servlet和tomcat的知識點有哪些”文章的知識點大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“servlet和tomcat的知識點有哪些”文章吧。

servlet是什么
為了能讓web服務(wù)器與web應(yīng)用這兩個不同的軟件系統(tǒng)協(xié)作,需要一套標準接口,servlet就是其中最主要的一個接口。

規(guī)定:

web服務(wù)器可以訪問任意一個web應(yīng)用中實現(xiàn)servlet接口的類。

web應(yīng)用中用于被web服務(wù)器動態(tài)調(diào)用的程序代碼位于servlet接口的實現(xiàn)類中。

sun公司(現(xiàn)在被oracle收購了……)制定了web應(yīng)用于web服務(wù)器進行協(xié)作的一系列標準java接口(統(tǒng)稱為java servlet api)。

sun公司還對web服務(wù)器發(fā)布及運行web應(yīng)用的一些細節(jié)做了規(guī)約。sun公司把這一系列標準java接口和規(guī)約統(tǒng)稱為servlet規(guī)范。

servlet是一種運行在服務(wù)器上的小插件。

servlet容器是什么

在servlet規(guī)范中,把能夠發(fā)布和運行javaweb應(yīng)用的web服務(wù)器稱為servlet容器,他的最主要特稱是動態(tài)執(zhí)行javaweb應(yīng)用中的servlet實現(xiàn)類中的程序代碼。

tomcat是什么

tomcat是servlet容器,同時也是輕量級的web服務(wù)器。

apache server、microsoft iis、apache tomcat都是web服務(wù)器。

tomcat作為web服務(wù)器時,主要負責(zé)實現(xiàn)http傳輸?shù)裙ぷ鳌?br/>

tomcat作為servlet容器時,主要負責(zé)解析request,生成servletrequest、servletresponse,將其傳給相應(yīng)的servlet(調(diào)用service( )方法),再將servlet的相應(yīng)結(jié)果返回。

tomcat組成結(jié)構(gòu)

servlet和tomcat的知識點有哪些

server,代表整個servlet容器組件,是tomcat的頂層元素。其中可以包含一到多個service;

service,包含一個engine,以及一到多個connector;

connector,代表和客戶端程序?qū)嶋H交互的組件,負責(zé)接收客戶請求,以及向客戶返回響應(yīng)結(jié)果;

engine,處理同一個service中所有connector接收到的客戶請求;

host,在engine中可以包含多個host,每個host定義了一個虛擬主機,它可以包含一個到多個web應(yīng)用;

context,一個host中可以包含多個context,每個context代表了運行在虛擬主機上的單個web應(yīng)用。

這些字段都在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>

以上就是關(guān)于“servlet和tomcat的知識點有哪些”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對大家有幫助,若想了解更多相關(guān)的知識內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI