Web/JSP
JSP) 에러페이지
surhommejk
2018. 3. 21. 10:49
web.xml에서의 에러 처리
<error-page>
<error-code>404</error-code>
<location>/error/error404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error/error500.jsp</location>
</error-page>
</web-app>
error-code에 해당하는 에러 발생시 설정한 location 페이지가 클라이언트에게 송출
~.jsp에서의 에러 처리
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page errorPage="/error/commonError.jsp" %> <!--web.xml 설정보다 우선된다 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<!-- 페이지마다 고유한 에러 페이지 설정
web.xml 설정이 있더라도
errorPage="/error/commonError.jsp" 설정이 우선한다
-->
<%
String data = request.getParameter("name").toLowerCase();
%>
전달받은 내용 : <%= data %>
</body>
</html>
에러 발생시 설정한 location 페이지가 클라이언트에게 송출
sample 에러 페이지