지금까지는 브라우저에서 요청하여 화면을 표시했음. 그런데 웹 애플리케이션 첫 화면에 해당하는 홈페이지를 다음과 같이 web.xml에 등록해 두며 브라우저에서는 컨텍스트 이름만으로 요청하여 간단하게 표시할 수 있음.
web.xml
<welcome-file-list>
<welcome-file> jsp 또는 html 파일 이름1 </welcome-file>
<welcome-file> jsp 또는 html 파일 이름2 </welcome-file>
</welcome-file-list>
요청 시 첫 번째로 지정한 welcome 파일부터 차례로 찾아 홈페이지로 보여줌.
예 1)
web.xml에 welcome-file-list 태그 경로를 포함해 홈페이지에 해당하는 파일들을 나열함.
<welcome-file-list>
<!-- 여러 개의 welcome 파일을 지정함. -->
<welcome-file>test02/main.jsp</welcome-file>
<welcome-file>test02/add.jsp</welcome-file>
<welcome-file>test02/add.html</welcome-file>
</welcome-file-list>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<img src = ".image/duke.jpg"/><br>
<h1>안녕하세요</h1>
<h1>쇼핑몰 중심 jsp 홈페이지 입니다.</h1>
</body>
</html>
브라우저 주소창에 /pro12 로만 요청하면됨.
Tip.
개발을 모두 마치고 실제 서비스를 제공할 때는 웹 사이트에 대한 도메인 이름을 구한 후 웹 호스팅 업체에서 제공하는 방법으로 브라우저에서 도메인 이름으로 요청해야 함. 그리고 다시 컨텍스트 이름으로 재요청하도록 설정하면 됨.