본문 바로가기
JSP

[ JSP ] Error page 설정 ( make error page)

by 정윤재 2018. 2. 8.

1. web.xml 에 http status code 에 맞게 아래와 같이 설정 한다.

  eng) setting web.xml file (set it according to the http status code)

example web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app>

<error-page>

  <error-code>404</error-code>

  <location>/error/404.jsp</location>

  <!-- full path except context root -->

 </error-page>

</web-app>


2. error jsp파일을 만든다

eng) make error jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8" isErrorPage="true"%>

<%

response.setStatus(200);

//http status code 를 200 으로 맞춰서 error 를 유추하지 못하게  

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>404 Error</title>

</head>

<body>

404 error

</body>

</html>





댓글