1. web.xml 세팅
2. error page 만들기
</div>
3. 기타 에러페이지 활용
ERROR PAGE에서 활용하는 방법
<error-page>
<error-code>401</error-code>
<location>/error/ExceptionPage.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/error/ExceptionPage.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/error/ExceptionPage.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/error/ExceptionPage.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error/ExceptionPage.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error/ExceptionPage.jsp</location>
</error-page>2. error page 만들기
<div style="width:100%; height:100%; background:#F0F2FB;">
<div style="margin:auto; width:600px; position:relative; top:40%;">
<div style="float:left;"><img src="/images/warning.gif" onDblClick="$('#errorLog').show();"/></div>
<div style="float:left; margin-left:20px;">
<font color="red">시스템에 오류가 발생했습니다. <br /></font>
잠시후 다시 시도해 보시고 지속적인 오류 발생시 관리자에게 문의해 주시기 바랍니다. <br/><br/>
<a href="javascript:history.back();">- 뒤로가기 -</a><br/>
</div>
<div id="errorLog" style="position:relative; clear:both; text-align:left; display:none;">
<pre>
Exception : ${pageContext.exception} ${pageContext.exception.message}
<c:forEach var="st" items="${pageContext.exception.stackTrace}">
${st} </c:forEach>
</pre>
</div>
</div>
3. 기타 에러페이지 활용
ERROR PAGE에서 활용하는 방법
${requestScope['javax.servlet.error.status_code']}
javax.servlet.error.status_code:
에러 상태 코드를 말해 주는 정수
javax.servlet.error.exception_type
에러가 생기게 된 예외 형을 지적해 주는 클래스 인스턴스
javax.servlet.error.message
예외 메시지를 말해주는 스트링이며, 예외 컨스트럭터로 보내어 진다.
javax.servlet.error.exception
실제 예외가 없어지면 버릴 수 있는 객체이다.
javax.servlet.error.request_uri
문제를 일으킨 리소스의 URI를 말해주는 스트링이다.
javax.servlet.error.servlet_name
Throwable e = (Throwable)request.getAttribute("javax.servlet.error.exception");
Throwable e1 = (Throwable)request.getAttribute("javax.servlet.jsp.jspException");
오류 페이지에서만 쓸 수 있는 객체 : exception
<%@ page isErrorPage="true" %>
${pageContext.exception}
오류 발생 후 오류 페이지로 이동하지 않고
자체 페이지에서 해결하기 : <c:catch>
<c:catch>
<% int x = 10/0; %>
// 에러가 발생하면 다음을 실행하지 않고 </c:catch>로 곧장 이동한다.
</c:catch>
exception을 속성으로 만들어 에러 메시지 읽기
<c:catch var="myException">
...
</c:catch>
${myException.message}
'Jsp-Servlet > Jsp' 카테고리의 다른 글
Excel Download 공통단 (1) | 2011.11.17 |
---|---|
quartz setting (servlet 이용) (3) | 2011.10.31 |
jstl el 특이한 명령어들.. (4) | 2011.01.09 |
custom tag lib 대략 정리 (1) | 2010.08.05 |
jstl, el, fn 정리 (2) | 2010.05.27 |