jsp---exception对象

exception对象用来处理错误异常

如果使用exception,则必须指定page中的isErrorPage为true

<%@ page language="java" contentType="text/html;charset=gb2312" import="java.util.*" isErrorPage="true"%>
<%@ page import="java.io.PrintStream" %>
<!DOCTYPE html>
<html>
	<head>
		<title>处理错误异常</title>
	</head>
	<body>
	
	<%=exception %><br />
	<%=exception.getMessage() %><br />
	<%=exception.getLocalizedMessage() %><br />
	
	<%
		exception.printStackTrace(new java.io.PrintWriter(out));
	%>
	</body>
</html>

<%@ page language="java" contentType="text/html;charset=gb2312" errorPage="ExceptionDemo.jsp"%>
<!DOCTYPE html>
<html>
	<head>
		<title>错误页面</title>
	</head>
	<body>
		<%
			int[] arr = {1,2,4};
			out.println(arr[3]);
		%>
		
	</body>
</html>

你可能感兴趣的:(jsp---exception对象)