The HttpServletResponse interface has fields as status codes.
e.g.
404 : SC_NOT_FOUND
500 : SC_INTERNAL_SERVER_ERROR
It is recommended to use status codes for the sendError method and sendStatus method.
sendError(int sc)
Returns an error response to the client using a specified status code.
sendError(int sc, String msg)
Returns an error response with a message.
setStatus(int sc)
Set the status code for the response.
e.g.
SC_OK (200)
SC_MOVED_TEMPORARILY (302)
You should use the sendError method for an error response.