찾다
Javajava지도 시간Java의 서블릿과 Tomcat에 대한 자세한 설명

Java의 서블릿과 Tomcat에 대한 자세한 설명

Jul 21, 2017 pm 04:15 PM
javaservlettomcat

이 글은 주로 서블릿과 톰캣을 소개하는데, 편집자가 보기에는 꽤 좋다고 생각해서 지금부터 참고용으로 올려보겠습니다. 에디터를 따라가며 함께 살펴볼까요

서블릿이란 무엇입니까
웹 서버와 웹 애플리케이션이라는 서로 다른 두 소프트웨어 시스템이 협력하려면 일련의 표준 인터페이스가 필요하며, 서블릿이 가장 중요합니다 그 중 중요한 인터페이스.

규정:

웹 서버는 모든 웹 애플리케이션에서 서블릿 인터페이스를 구현하는 모든 클래스에 액세스할 수 있습니다.

웹 애플리케이션에서 웹 서버가 동적으로 호출하는 데 사용되는 프로그램 코드는 서블릿 인터페이스의 구현 클래스에 있습니다.

SUN Company(현재 Oracle에 인수됨...)는 웹 애플리케이션이 웹 서버와 협력하기 위한 일련의 표준 Java 인터페이스(Java Servlet API라고 함)를 개발했습니다.

SUN은 웹 서버 게시 및 웹 애플리케이션 실행에 대한 몇 가지 세부 정보도 지정합니다. SUN Corporation에서는 이 일련의 표준 Java 인터페이스 및 사양을 서블릿 사양이라고 부릅니다.

서블릿은 서버에서 실행되는 작은 플러그인입니다.

서블릿 컨테이너란 무엇입니까

서블릿 사양에서는 JavaWeb 애플리케이션을 게시하고 실행할 수 있는 웹 서버를 서블릿 컨테이너라고 하며, 주요 특수 이름은 동적으로 실행되는 JavaWeb 애플리케이션의 서블릿 구현 클래스입니다. 프로그램 코드.

Tomcat이란 무엇입니까?

Tomcat은 서블릿 컨테이너이자 경량 웹 서버입니다.

Apache Server, Microsoft IIS 및 Apache Tomcat은 모두 웹 서버입니다.

Tomcat이 웹 서버 역할을 할 때 주로 HTTP 전송 및 기타 작업 구현을 담당합니다.

Tomcat이 서블릿 컨테이너 역할을 할 때 주로 Request 구문 분석, ServletRequest 및 ServletResponse 생성, 해당 서블릿에 전달(service() 메서드 호출), 해당 서블릿 결과 반환을 담당합니다.

Tomcat 구성 구조

Server는 전체 Servlet 컨테이너 구성 요소를 나타내며 Tomcat의 최상위 요소입니다. 하나 이상의 서비스를 포함할 수 있습니다.

서비스에는 엔진과 하나 이상의 커넥터가 포함됩니다.

커넥터는 실제로 클라이언트 프로그램과 상호 작용하고 고객 요청을 수신하고 결과를 반환하는 역할을 담당합니다. ;

엔진은 동일한 서비스의 모든 커넥터에서 수신한 고객 요청을 처리합니다.

호스트, 엔진은 여러 호스트를 포함할 수 있으며, 각 호스트는 하나 또는 여러 개의 웹 애플리케이션을 포함할 수 있는 가상 호스트를 정의합니다. , 호스트는 여러 컨텍스트를 포함할 수 있으며, 각 컨텍스트는 가상 호스트에서 실행되는 단일 웹 애플리케이션을 나타냅니다.

이러한 필드는 conf/server.xml에 구성되어 있습니다. 다음은 Apache Tomcat 6.0.36의 기본 server.xml입니다.


<?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?> 
<!-- 
 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>

위 내용은 Java의 서블릿과 Tomcat에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
고급 Java 프로젝트 관리, 구축 자동화 및 종속성 해상도에 Maven 또는 Gradle을 어떻게 사용합니까?고급 Java 프로젝트 관리, 구축 자동화 및 종속성 해상도에 Maven 또는 Gradle을 어떻게 사용합니까?Mar 17, 2025 pm 05:46 PM

이 기사에서는 Java 프로젝트 관리, 구축 자동화 및 종속성 해상도에 Maven 및 Gradle을 사용하여 접근 방식과 최적화 전략을 비교합니다.

적절한 버전 및 종속성 관리로 Custom Java 라이브러리 (JAR Files)를 작성하고 사용하려면 어떻게해야합니까?적절한 버전 및 종속성 관리로 Custom Java 라이브러리 (JAR Files)를 작성하고 사용하려면 어떻게해야합니까?Mar 17, 2025 pm 05:45 PM

이 기사에서는 Maven 및 Gradle과 같은 도구를 사용하여 적절한 버전 및 종속성 관리로 사용자 정의 Java 라이브러리 (JAR Files)를 작성하고 사용하는 것에 대해 설명합니다.

카페인 또는 구아바 캐시와 같은 라이브러리를 사용하여 자바 애플리케이션에서 다단계 캐싱을 구현하려면 어떻게해야합니까?카페인 또는 구아바 캐시와 같은 라이브러리를 사용하여 자바 애플리케이션에서 다단계 캐싱을 구현하려면 어떻게해야합니까?Mar 17, 2025 pm 05:44 PM

이 기사는 카페인 및 구아바 캐시를 사용하여 자바에서 다단계 캐싱을 구현하여 응용 프로그램 성능을 향상시키는 것에 대해 설명합니다. 구성 및 퇴거 정책 관리 Best Pra와 함께 설정, 통합 및 성능 이점을 다룹니다.

캐싱 및 게으른 하중과 같은 고급 기능을 사용하여 객체 관계 매핑에 JPA (Java Persistence API)를 어떻게 사용하려면 어떻게해야합니까?캐싱 및 게으른 하중과 같은 고급 기능을 사용하여 객체 관계 매핑에 JPA (Java Persistence API)를 어떻게 사용하려면 어떻게해야합니까?Mar 17, 2025 pm 05:43 PM

이 기사는 캐싱 및 게으른 하중과 같은 고급 기능을 사용하여 객체 관계 매핑에 JPA를 사용하는 것에 대해 설명합니다. 잠재적 인 함정을 강조하면서 성능을 최적화하기위한 설정, 엔티티 매핑 및 모범 사례를 다룹니다. [159 문자]

Java의 클래스로드 메커니즘은 다른 클래스 로더 및 대표 모델을 포함하여 어떻게 작동합니까?Java의 클래스로드 메커니즘은 다른 클래스 로더 및 대표 모델을 포함하여 어떻게 작동합니까?Mar 17, 2025 pm 05:35 PM

Java의 클래스 로딩에는 부트 스트랩, 확장 및 응용 프로그램 클래스 로더가있는 계층 적 시스템을 사용하여 클래스로드, 링크 및 초기화 클래스가 포함됩니다. 학부모 위임 모델은 핵심 클래스가 먼저로드되어 사용자 정의 클래스 LOA에 영향을 미치도록합니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

SecList

SecList

SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구

안전한 시험 브라우저

안전한 시험 브라우저

안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.