How to send an error code using JSP to browser?


Following example shows how a 407 error code is sent to the client browser. After this, the browser would show you "Need authentication!!!" message.

<html>
   <head>
      <title>Setting HTTP Status Code</title>
   </head>
   <body>
      <%
         // Set error code and reason.
         response.sendError(407, "Need authentication!!!" );
      %>
   </body>
</html>

You will receive the following output −

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

Updated on: 30-Jul-2019

257 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements