HTTP 상태 500 – 내부 서버 오류 : 프로그램 코딩 문제
내장 객체 : out / response / request / exception / session
프로토콜
[계산 : 15_errorPage.jsp] <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page isErrorPage="true" %> <% response.setStatus(200); %><!-- F12 Network의 Status Code를 변경 --> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> 죄송합니다. 당신의 신뢰를 지키겠습니다.<br/> <%=exception.getMessage() %> </body> </html> -------------------------------------------------------------------------- [계산 : 15_info.jsp] <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page errorPage="15_errorPage.jsp"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% int i = 40/0; %> </body> </html>
[결과값] Cookie : Request Headers에 같이 포함됨
[계산 : web.xml] <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0"> <display-name>servelt_example</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/15_error404.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/15_error500.jsp</location> </error-page> </web-app> -------------------------------------------------------------------------- [계산 : 15_error500.jsp] <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%-- <%@ page errorPage="15_errorPage.jsp"%> --%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> 500에러입니다. 열심히 하겠습니다. 반성합니다. 다시는 이런 에러 없도록 하겠습니다. </body> </html> -------------------------------------------------------------------------- [계산 : 15_error404.jsp] <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%-- <%@ page errorPage="15_errorPage.jsp"%> --%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> 404에러입니다. </body> </html>
[결과값]