"Sets the status code for this response. This method is used to set the return status code when there is no error (for example, for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there is an error, and the caller wishes to invoke an error-page defined in the web application, the sendError method should be used instead. The container clears the buffer and sets the Location header, preserving cookies and other headers. "
Remember setStatus() is used to set a header when there is NO ERROR.
sendError() in HttpServletResponse is defined as follows