-
Tomcat - web.xml공부 이야기/Spring 2022. 12. 25. 16:13
공식 문서
/WEB-INF/web.xml - The Web Application Deployment Descriptor for your application. This is an XML file describing the servlets and other components that make up your application, along with any initialization parameters and container-managed security constraints that you want the server to enforce for you. This file is discussed in more detail in the following subsection.
As mentioned above, the /WEB-INF/web.xml file contains the Web Application Deployment Descriptor for your application. As the filename extension implies, this file is an XML document, and defines everything about your application that a server needs to know (except the context path, which is assigned by the system administrator when the application is deployed).The complete syntax and semantics for the deployment descriptor is defined in Chapter 13 of the Servlet API Specification, version 2.3. Over time, it is expected that development tools will be provided that create and edit the deployment descriptor for you. In the meantime, to provide a starting point, a basic web.xml file is provided. This file includes comments that describe the purpose of each included element.
NOTE - The Servlet Specification includes a Document Type Descriptor (DTD) for the web application deployment descriptor, and Tomcat enforces the rules defined here when processing your application's /WEB-INF/web.xml file. In particular, you must enter your descriptor elements (such as <filter>, <servlet>, and <servlet-mapping> in the order defined by the DTD (see Section 13.3).
https://tomcat.apache.org/tomcat-9.0-doc/appdev/deployment.html
Application Developer's Guide (9.0.70) - Deployment
Before describing how to organize your source code directories, it is useful to examine the runtime organization of a web application. Prior to the Servlet API Specification, version 2.2, there was little consistency between server platforms. However, serv
tomcat.apache.org
요약)
- 웹애플리케이션에 대한 배포 지시서로 고유성을 지님
- 서블릿과 다른 구성요소들이 기술된 xml 파일
* 다른 구성 요소 : 초기화 변수 및 제한된 보안 컨텐츠들로 구성
- 서버가 애플리케이션을 구동할 때 알아야할 정보
Tomcat - example
https://tomcat.apache.org/tomcat-9.0-doc/appdev/web.xml.txt
<context-param> : Web application's servlet context initialization parameters. -> /META-INF/context.xml
https://tomcat.apache.org/tomcat-8.5-doc/config/context.html
Apache Tomcat 8 Configuration Reference (8.5.84) - The Context Container
When autoDeploy or deployOnStartup operations are performed by a Host, the name and context path of the web application are derived from the name(s) of the file(s) that define(s) the web application. Consequently, the context path may not be defined in a M
tomcat.apache.org
<filter> : . A filter intercepts a request for a specific named resource or a group of resources (based on a URL pattern) and executes the code in the filter.
- doFilter() 메소드의 전달인자인 ServletRequest, ServletResponse로 요청/응답 파라미터에 접근 가능
<Listener> : Name of the class that responds to a Web application event.
- 웹 애플리케이션의 시작과 종료 혹은 컨테이너에 저장된 속성 값에 변화가 있을 때
- HTTP 세션의 활성화/비활성화, 내부 속성 값의 변경이 있을 때
- javax.servlet.ServletContextListener을 상속받아 위 기능 구현 가능
- javax.servlet.ServletContextEvent 객체로 Context 정보 접근 가능
<servlet> : name, class, init-param으로 구성
서블릿 클래스와 매핑되며 init-param으로 초기 변수 설정 가능
<servlet-mapping> : URL 패턴에 따라 서블릿 경로 설정 가능 -> DispatcherServlet.java
<session-config> : 세션 유지 시간 설정 가능
<resource-ref> : JDBC와 같은 드라이버 설정 가능 -> /META-INF/context.xml
<mime-mapping> : text/plain, img, gif 등의 멀티미디어 타입 정보 기술
<welcome-file-list> : 시작 페이지 설정
<multipart-config> : 최대 파일 사이즈(50MB) 설정 가능
<display-name> : Application name
<description> : 주석
<login-config> : configure how the user is authenticated
<form-login-config> : FORM-based authentication that conforms to a specific naming convention.
<security-role> : mapping between a Web application security role
<security-constraint> :
<web-app> : 필수값, 스키마 설정
<error-page> : error.jsp 표시 가능
Oracle Docs (WebLogic)
https://docs.oracle.com/cd/E17904_01/web.1111/e13712/web_xml.htm#WBAPP502
A web.xml Deployment Descriptor Elements
21/23 A web.xml Deployment Descriptor Elements The following sections describe the deployment descriptor elements defined in the web.xml schema under the root element . With Java EE annotations, the standard web.xml deployment descriptor is optional. Accor
docs.oracle.com
'공부 이야기 > Spring' 카테고리의 다른 글
JWT : JSON Web Token (0) 2024.02.11 H2 기본 자료형 (0) 2023.12.30 톰캣이 서블릿 컨테이너를 부팅하는 과정 (0) 2022.12.25 개같은 스프링 <7> (0) 2020.02.07 개같은 스프링 <6> (0) 2020.02.07