{title:'HTTP Status Codes', updated:'9.0.0'}

By default, a 200 (OK) status is automatically set as the HTTP status when a Java method executes successfully.

Other status codes can be generated by throwing a {@link oaj.http.response.BasicHttpException} with a specific HTTP status code, or calling {@link javax.servlet.http.HttpServletResponse#setStatus(int)}.

Non-OK (200) status codes are automatically triggered by the following conditions:

Code | Description | When triggered
--- | --- | ---
401 | Unauthorized | A {@link oajr.guard.RestGuard guard} prevented the method from being executed
404 | Not Found | No matching path patterns were found on any method
405 | Method Not Implemented | A path pattern matched, but no Java methods were found for the HTTP method
406 | Not Acceptable | A path pattern matched, but no Java methods were found with a matching serializer for the Accept on the request
412 | Precondition Failed | A path pattern matched, but no Java methods were found that were not rejected by {@link oajr.RestMatcher matchers}
415 | Unsupported Media Type | A path pattern matched, but no Java methods were found with a matching parser for the Content-Type on the request
500 | Internal Server Error | The Java method threw an exception other than {@link oaj.http.response.BasicHttpException}