<%@ page language="java" contentType="text/html; charset=utf-8" errorPage="exception.jsp"%>
<!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=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1>exception内置对象</h1>
<hr>
<%
System.out.println(100/0);
%>
</body>
</html>
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=utf-8" isErrorPage="true"%>
<!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=utf-8">
<title>Insert title here</title>
</head>
<body>
异常的消息是:<%=exception.getMessage() %><br>
异常的字符串描述:<%=exception.toString() %>
<%=exception.printStackTrace() %>
</body>
</html>
统一设置异常跳转页
在web.xml里,
<error-page>
<error-code>500</error-code>
<location>NewFile1.jsp</location>
</error-page>