Reputation: 1689
I want to have a custom error code in my JSP, to prevent a special condition from happening:
boolean error;
// do error checking here
if (error) {
throw new javax.xml.ws.http.HTTPException(400);
}
However, this ends up throwing a 500 to the client, since the server interprets the exception as an internal issue. How can I send a status of 400 to the client?
Upvotes: 2
Views: 3008
Reputation: 12453
You should be able to send it through the response object:
<%
response.sendError(418, "I'm a teapot" );
%>
Upvotes: 4