You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `<hs:cause/>` tag displays the cause of current HTTP status code, if any. A shorthand for:
120
120
@@ -129,15 +129,15 @@ Optional attributes are:
129
129
|`default`| The fallback value to output, if no cause is |
130
130
|`escapeXml`| Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. |
The `<hs:message/>` tag displays the current error message, if any. A shorthand for:
143
143
@@ -152,7 +152,7 @@ Optional attributes are:
152
152
|`default`| The fallback value to output, if no error message is available. |
153
153
|`escapeXml`| Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. |
The `<hs:reason/>` tag displays the reason for an HTTP status code, if any. Optional attributes are:
158
158
@@ -164,13 +164,14 @@ The `<hs:reason/>` tag displays the reason for an HTTP status code, if any. Opti
164
164
165
165
## StatusCode
166
166
167
-
The `StatusCode` bean can be used to check the class of the status code error.
167
+
The [StatusCode](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html) bean can be used to check the class of the status code error.
168
168
169
169
For example, in Java:
170
170
171
171
```java
172
-
if (StatusCode.isServerError(500)) {
173
-
System.out.println(Reasons.getReasonPhrase(500)); // Internal Server Error
172
+
var statusCode =newStatusCode(500);
173
+
if (statusCode.isError()) {
174
+
System.out.println(statusCode.getReason()); // Internal Server Error
174
175
}
175
176
```
176
177
@@ -212,37 +213,39 @@ public class ExampleServlet extends HttpServlet {
212
213
}
213
214
```
214
215
215
-
The `StatusCode` bean methods are:
216
+
The [StatusCode](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html) bean methods are:
|[getReason](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#getReason())| Returns the reason for the status code (e.g. `Internal Server Error`) |
221
+
|[isClientError](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#isClientError())| Checks if the status code is a client error. |
222
+
|[isError](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#isError())| Checks if the status code is a server or client error. |
223
+
|[isInfo](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#isInfo())| Checks if the status code is informational. |
224
+
|[isRedirect](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#isRedirect())| Checks if the status code is a redirect. |
225
+
|[isServerError](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#isServerError())| Checks if the status code is a server error. |
226
+
|[isSuccess](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#isSuccess())| Checks if the status code is a success. (`OK`) |
227
+
|[isValid](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#isValid())| Checks if the status code is valid. |
228
+
229
+
These methods are also available as [static methods](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCode.html#method-summary`).
227
230
228
231
### Status Code Class
229
232
230
-
You can also retrieve all status codes in a specific [class](https://www.rfc-editor.org/rfc/rfc9110.html#name-status-codes):
233
+
The [StatusCodeClass](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCodeClass.html)can be used to retrieve all status codes in a specific [class](https://www.rfc-editor.org/rfc/rfc9110.html#name-status-codes):
231
234
232
235
```java
233
236
var reasons =Reasons.getReasonClass(StatusCodeClass.SERVER_ERROR); // 5xx
|[INFORMATIONAL](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCodeClass.html#INFORMATIONAL)| 1xx | The request was received, continuing process |
245
+
|[SUCCESSFUL](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCodeClass.html#SUCCESSFUL)| 2xx | The request was successfully received, understood, and accepted |
246
+
|[REDIRECTION](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCodeClass.html#REDIRECTION)| 3xx | Further action needs to be taken to complete the request |
247
+
|[CLIENT_ERROR](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCodeClass.html#CLIENT_ERROR)| 4xx | The request contains bad syntax or cannot be fulfilled |
248
+
|[SERVER_ERROR](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCodeClass.html#SERVER_ERROR)| 5xx | The server failed to fulfil an apparently valid request |
0 commit comments