web.xml
http_error.jsp
<error-page>
<error-code>404</error-code>
<location>/http_error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/http_error.jsp</location>
</error-page>
http_error.jsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<%
Integer errorCode = (Integer)request.getAttribute("javax.servlet.error.status_code");
if(errorCode == 404){
response.sendRedirect(request.getContextPath() + "/404.jsp");
}else if(errorCode == 500){
response.sendRedirect(request.getContextPath() + "/500.jsp");
}
%>
</body>
</html>