JSP 3. Exception
2014. 7. 26. 14:54ㆍ구_Programming/JSP
try {
}catch(NumberFormatException e) {
RequestDispatcher dispatcher = request.getRequestDispatcaher("ErrorPage.jsp");
dispatcher.forward(request, response);
}
<%@page errorPage ="errorPage.jsp" %>
JSP 페이지에서 에러 페이지 호출하기
JSP 페이지에는 기본적으로 exception 내장 변수가 생기지 않기때문에 page 지시자에서 isErrorPage라는 애트리뷰트를 쓰고 true 값으로 지정해야 함
<%@page isErrorPage ="true" %>
String message = exception.getMessage();
web.xml 파일에 에러페이지 등록하기
<error-page>
<exception-type>java.lang.NumberFormatException</exception-type>
<location>/NubmerformatError.jsp</location>
</error-page>
'구_Programming > JSP' 카테고리의 다른 글
JSP 6. JSTL (0) | 2014.07.26 |
---|---|
JSP 5. Action tag (0) | 2014.07.26 |
JSP 4. EL(Expression Language) (0) | 2014.07.26 |
JSP 2. 기초, 쿠키와 세션 (0) | 2014.07.26 |
JSP 1. 서블릿, JSP (0) | 2014.07.26 |