sitelink1 | |
---|---|
sitelink2 | |
extra_vars5 | |
extra_vars6 |
web.xml이란
Deployment Descriptor로 각 어플리케이션의 환경을 설정하는 부분을 담당한다. WAR 파일이 패키지 될 때 같이 포함되며 root directory 밑에 /WEB-INF 디렉토리에 위치한다.
web.xml 의 구조
xml 정의와 schema 선언
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd> |
웹 어플리케이션의 환경 설정 <web-app>
<servlet>
<servlet-name>사용되는 클래스명</servlet-name>
<servlet-class>클래스 경로</servlet-class>
</servlet>
<mime-mapping>
<extension>txt</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>기본 파일 경로</welcome-file>
<welcome-file>두번째 시작하는 파일 경로</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>태그라이브러리</taglib-uri>
<taglib-location>경로</taglib-location>
</taglib>
</web-app>
web.xml은 xml파일이다. 따라서 xml 작성과 동일한 규칙이 적용된다.
환경설정은 <web-app>으로 시작하고 </web-app>로 끝난다. 그외 삽입되는 요소로는 다음과 같다.
.ServletContext Init Parameters
.Session Configuration
.Servlet/JSP Definitions
.Servlet/JSP Mappings
.Mime Type Mappings
.Welcom File list
.Error Pages
web.xml의 elements의 순서
각 element의 순서는 아래 순서에 따른다.
<icon?>, <display-name?>, <description?>, <distributable?>, <context-param*>, <filter*>, <filter-mapping*>, <listener*>, <servlet*>, <servlet-mapping*>, <session-config?>, <mime-mapping*>, <welcome-file-list?>, <error-page*>, <taglib*>, <resource-env-ref*>, <resource-ref*>, <security-constraint*>, <login-config?>, <security-role*>, <env-entry*>, <ejb-ref*>, <ejb-local-ref*> |
자주 쓰이는 elements 예제
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app> |
* 만약 톰캣 4에서 servelt에 접근이 안되는 경우
아래는 okjsp.pe.kr 운영자 kenu님의 처리 방법이다.
invoker 서블릿의 매핑이 보안문제로 막혀있어서 발생하는 문제로 $CATALINA_HOME/conf/web.xml를 열고 해당 부분의 주석을 제거한다. <!-- The mapping for the invoker servlet --> security-constraint 엘리먼트를 $CATALINA_HOME/conf/web.xml 파일의 welcome-file-list 엘리먼트 아래쪽 <web-app> 에 중첩되게 복사합니다. <welcome-file-list> |
web.xml 태그 작성 순서
http://java.sun.com/dtd/web-app_2_3.dtd
icon
display-name
description
distributable
context-param*
filter*
filter-mappiing*
servlet*
servlet-mapping*
session-config
mime-mapping
welcome-file-list
error-page*
tablib*
resource-env-ref*
reource-ref*
security-constraint*
login-coonfig
security-role
env-entry
ejb-ref
ejb-local-ref
태그 순서가 맞아야 에러가 발생하지 않습니다
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
14 | [phind] jetty 와 tomcat 의 차이점 (성능, 사용성, 선호도) | 황제낙엽 | 2024.10.31 | 237 |
13 | iis error - Service Unavailable / HTTP Error 503. The service is unavailable. | 황제낙엽 | 2020.09.23 | 700 |
12 | 웹사이트에서 여러 도메인을 사용하는 방법 | 황제낙엽 | 2020.03.04 | 153 |
11 | 안전한 웹사이트 설정하기 (.htaccess 및 .htpasswd 사용법) | 황제낙엽 | 2019.07.21 | 338 |
10 | SSL, Https를 위한 인증서 발급 | 황제낙엽 | 2019.02.20 | 213 |
9 |
아파치 ETag 이용한 정적파일 최적화
![]() | 황제낙엽 | 2012.05.30 | 1304 |
8 | 웹서버의 응답 코드에 대한 내용 (SIP Response code-v2) | 황제낙엽 | 2010.03.22 | 442 |
7 | htpasswd.exe 로 사용자 추가하기 | 황제낙엽 | 2009.09.01 | 183 |
6 | TUXEDO - Server Grouping에 대하여 | 황제낙엽 | 2007.04.18 | 227 |
» | web.xml 태그 작성 순서 | 황제낙엽 | 2006.02.24 | 357 |
4 | 웹어플리케이션 셋팅 (web.xml 엘레멘트 설명) | 황제낙엽 | 2007.02.22 | 332 |
3 | httpd.conf 파일 완벽 가이드(1.3X) | 황제낙엽 | 2006.12.27 | 177 |
2 | HTML input form charset tip (WebLogic Server) | 황제낙엽 | 2005.12.01 | 139 |
1 | Evermind Orion Application Server 설치방법 | 황제낙엽 | 2004.02.11 | 152 |