IT 전용글/JSP

Exception 처리 방식

회상형인간 2009. 1. 30. 11:54
1) web.xml 파일에 해당 코드 추가
<error-page>
  <exception-type>java.sql.SQLException</exception-type>
  <location>/sql_error.jsp</location>
 </error-page>
또는
<error-page>
  <error-code>500</error-code>
  <location>/500.jsp</location>
 </error-page>
이걸로..

2) Exception  메소드 단에서 모두 thorws로 변환 한다 (컨테이너가 처리하게끔)

3) invoke -> 컨테이너 -> 셋팅된 에러페이지로 포워딩 시킨다.

4) 포워딩된 응답객체에는 에러코드가 들어가있기 때문에

에러코드를 변환시켜주는 작업을 sql_error.jsp 파일에서 해주어야한다.


ex) sql_error.jsp 파일

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR" isErrorPage="true"%>
<%  response.setStatus(200); %>

 

 
 

'IT 전용글 > JSP' 카테고리의 다른 글

Transaction 참고 소스..  (0) 2009.02.13
JSP 멀티 업로드  (0) 2009.02.10
CustomTag (Not Struts CustomTag) 설정방법.  (0) 2009.01.30
국제화 .  (0) 2009.01.30
JSTL , CustomTag , 국제화  (0) 2009.01.29