?? 0170.htm
字號(hào):
<html>
<head>
<title>新時(shí)代軟件教程:操作系統(tǒng) 主頁(yè)制作 服務(wù)器 設(shè)計(jì)軟件 網(wǎng)絡(luò)技術(shù) 編程語(yǔ)言 文字編輯</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋體}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1 {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
<p align="center"><big><strong>錯(cuò)誤處理的例子</strong></big></p>
<div align="right">---摘自互聯(lián)網(wǎng)</div>
<br><!--<br>
errorHandler.jsp<br>
<br>
This JSP is invoked if the following conditions are met:<br>
<br>
1. An exception type or an HTTP Status code is mapped<br>
to this JSP using the Error Pages page of the<br>
Web Application Admin UI<br>
<br>
2. The specified Status Code is returned upon accessing a resource<br>
in the Web Application, OR the specifed Exception type is thrown<br>
as a result of processing a SERVLET request (not a JSP request).<br>
<br>
NOTE: In the case that a JSP page throws the specified Exception<br>
(rather than a Servlet), the error handling mechanism is<br>
completely unrelated to the settings on the Error Pages page<br>
of the Web Application admin UI.<br>
<br>
Instead the following scheme is used:<br>
<br>
1. The offending JSP names the error handling JSP as being it's<br>
error page using a page directive.<br>
<br>
2. The error handling JSP must declare itself to be an <br>
errorpage by using a page directive.<br>
<br>
See the top of p. 33 of the JSP 1.0 Specification for more information<br>
regarding this mechanism.<br>
<br>
<br>
Whenever this page is invoked, it tries to tell you what the error condition is<br>
(HTTP Status Code or Exception). If it cannot determine the condition, it will<br>
tell you that it could not determine the condition. Therefore, invoking it directly from<br>
your browser is not really useful.<br>
--><br>
<br>
<br>
<!--<br>
The following directive allows this JSP to access an Exception that may<br>
have been thrown by another JSP.<br>
--><br>
<%@ page isErrorPage="true" %><br>
<br>
<html><br>
<head><br>
<title>Error Handling JSP</title><br>
<br>
<style type="TEXT/CSS"><br>
<!--<br>
H2, H3, H4 { font-family: Verdana, Arial, sans-serif }<br>
TH { font-family: Verdana, Arial, sans-serif; font-size: 10pt; font-weight: bold }<br>
.headerText { font-family: Verdana, Arial, sans-serif; font-size: 10pt; font-weight: bold }<br>
P, UL, LI, BLOCKQUOTE { font-family: Verdana, Arial, sans-serif; font-size: 10pt }<br>
.normalText { font-family: Verdana, Arial, sans-serif; font-size: 10pt }<br>
.alertText { font-family: Verdana, Arial, sans-serif; font-size: 10pt; font-weight: bold; color: red }<br>
.errorText { font-family: Verdana, Arial, sans-serif; font-size: 14pt; font-weight: bold; color: red }<br>
.infoText { font-family: Verdana, Arial, sans-serif; font-size: 14pt; font-weight: bold; color: green }<br>
--><br>
</style><br>
<head><br>
<br>
<%<br>
Integer statusCode = null;<br>
String message = null;<br>
Exception excep = null; <br>
Throwable t = null; //for Exceptions thrown by another JSP<br>
<br>
//try to get the HTTP status code OR the Exception thrown by a Servlet<br>
statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");<br>
message = (String) request.getAttribute("javax.servlet.error.message");<br>
excep = (Exception) request.getAttribute("javax.servlet.error.exception_type");<br>
<br>
String problem, explanation;<br>
<br>
//try to get the exception thrown by a JSP (note: the implicit "exception" could be used here instead)<br>
t = (Throwable) request.getAttribute("javax.servlet.jsp.jspException");<br>
<br>
if(statusCode != null)<br>
{<br>
message = (message == null ? "No description available." : message);<br>
<br>
problem = "HTTP Status Code - " +statusCode.intValue();<br>
explanation = message;<br>
}<br>
<br>
//process an exception thrown by a Servlet (not a JSP)<br>
else if(excep != null)<br>
{<br>
problem = "An Exception was thrown while trying to process your request";<br>
explanation = excep.toString();<br>
}<br>
<br>
//process an exception thrown by another JSP (note: here is where a test using the implicit "exception"<br>
//such as exception != null, followed by explanation = exception.getMessage() could be used instead).<br>
<br>
else if(t != null)<br>
{<br>
problem = "An Exception was thrown while trying to process your request";<br>
explanation = t.toString();<br>
}<br>
<br>
else<br>
{<br>
problem = "Unknown";<br>
explanation = "The exact cause of the error could not be determined";<br>
}<br>
%><br>
<br>
<body bgcolor=#ffffff><br>
<div style="margin: 2%"><br>
<p class="errorText"><br>
!An Error Occurred while processing your request.<br>
</p><br>
<br>
<p></p><br>
<br>
<br>
<table border=1 width="96%" cellspacing=2 cellpadding=6 bgcolor=#ffcc66><br>
<tr><br>
<th>Problem</th><br>
<th>Explanation</th><br>
</tr><br>
<br>
<tr><br>
<td align="center" bgcolor=#ffffee class="normalText"><br>
<%=problem%><br>
</td><br>
<br>
<td bgcolor=#ffffee class="normalText"><br>
<%=explanation%><br>
</td><br>
</tr><br>
<br>
</table> <br>
<br>
<p>Go to the <a href="<%=request.getContextPath() + "/admin"%>">admin UI for <%=request.getContextPath().substring(1)%></a><br>
</div><br>
</body><br>
<br>
</html>
</table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -