如何使用 JSP 向瀏覽器傳送錯誤程式碼?
以下示例展示如何向客戶端瀏覽器傳送 407 錯誤程式碼。傳送後,瀏覽器將顯示“需要身份驗證!!!”訊息。
<html>
<head>
<title>Setting HTTP Status Code</title>
</head>
<body>
<%
// Set error code and reason.
response.sendError(407, "Need authentication!!!" );
%>
</body>
</html>你將收到以下輸出 −
HTTP Status 407 - Need authentication!!!
type Status report
message Need authentication!!!
description The client must first authenticate itself with the proxy (Need authentication!!!).
Apache Tomcat/5.5.29
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP