[JSP] 6.4 예외 종류별 에러 페이지 지정하기
2022. 4. 8. 13:14ㆍJAVA/Servlet&JSP
WEB-INF/web.xml
<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/Chapter06/error/errorNullPointer.jsp</location>
</error-page>
</web-app>
- 기존 에러 코드 대신 exception-type을 설정하여 예외 종류별 에러 페이지 지정
error/errorNullPointer.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
response.setStatus(HttpServletResponse.SC_OK);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<b>서비스 처리 과정에서 널(NULL) 예외가 발생하였습니다.</b>
</body>
</html>
02_readParameter2.jsp
<%@ 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>
<%/*name 파라미터의 값을 대문자로 변환하여 출력한다.
name 파라미터가 존재하지 않을 경우 예외가 발생한다.
*/ %>
name 파라미터 값 : <%= request.getParameter("name").toUpperCase() %>
</body>
</html>
References
source code : https://github.com/yonghwankim-dev/JSP2.0/tree/master/jsp2/src/main/webapp/Chapter06
JSP 2.0 프로그래밍 기초부터 중급까지
'JAVA > Servlet&JSP' 카테고리의 다른 글
[JSP] 7.1 <jsp:forward> 액션 태그를 이용한 JSP 페이지 이동 (0) | 2022.04.08 |
---|---|
[JSP] 6.5 에러 페이지의 우선 순위 및 에러 페이지 지정 형태 (0) | 2022.04.08 |
[JSP] 6.3 에러 코드별 에러 페이지 작성하기 (0) | 2022.04.08 |
[JSP] 6.2 에러 페이지 작성하기 (0) | 2022.04.08 |
[JSP] 6.1 에러 페이지 지정하기 (0) | 2022.04.08 |