Like ordinary Java programs, you can introduce exceptions into
JSPIn If you are performing
JSPJava code, you can forward HTTP requests to another Web page that specifically handles exceptions with the following instructions:
<%@ page
ErrorPage="
ErrorPage.
JSP"%>
In a Web page that handles an exception, the page should be treated as an exception by using the following statement
<%@ page iserrorpage= "true"%>
You can access the exception implicit object directly in the Web page that handles the exception, obtaining detailed exception information, such as
<p>
The reason for the error is: <% exception.printstacktrace (New PrintWriter (out));%>
</p>
The following creates an exception that may be thrown
JSPWeb Jspsum.
JSP, go to the sum of two parameters. If the customer enters an argument that cannot be converted to an integer, a numberformatexception is thrown, and the customer request is diverted
ErrorPage.
JSP
<p>
The parameters you enter (Num1=<%=request.getparameter ("NUM1")%>
Num2=<%=request.getparameter ("num2")%>) error
</p>
<p>
The reason for the error is: <% exception.printstacktrace (New PrintWriter (out));%>
</p>
</body>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.