Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> การเขียนโปรแกรม

วิธีส่ง Error Code ด้วย JSP ไปยัง Browser


ตัวอย่างต่อไปนี้แสดงวิธีส่ง Error Code 407 ไปยัง Client Browser หลังจากนี้ Browser จะแสดงข้อความ "Need authentication!!!"

<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