From 3bedb107052a08cd90c3e1b993908e3f3ae8dc29 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 20 Aug 2023 16:48:08 -0700 Subject: [PATCH] Cleaned up README --- README.md | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index de8f239..b844171 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,9 @@ The `` tag displays the cause of current HTTP status code, if any. A Optional attributes are: -| Attribute | Description | -|-------------|----------------------------------------------------------------------------------------------------------| -| `default` | The fallback value to output, if no cause is | +| Attribute | Description | +|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------| +| `default` | The fallback value to output, if no cause is | | `escapeXml` | Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. | ## hs:code @@ -94,19 +94,19 @@ The `` tag displays the current error message, if any. A shorthand Optional attributes are: -| Attribute | Description | -|-------------|----------------------------------------------------------------------------------------------------------| -| `default` | The fallback value to output, if no error message is available. | +| Attribute | Description | +|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------| +| `default` | The fallback value to output, if no error message is available. | | `escapeXml` | Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. | ## hs:reason -The `` tag displays the reason for a HTTP status code, if any. Optional attributes are: +The `` tag displays the reason for an HTTP status code, if any. Optional attributes are: -| Attribute | Description | -|-------------|----------------------------------------------------------------------------------------------------------| -| `default` | The fallback value to output, if no reason is available. | -| `code` | The HTTP status error code. If not specified the current status code is used. | +| Attribute | Description | +|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------| +| `default` | The fallback value to output, if no reason is available. | +| `code` | The HTTP status error code. If not specified the current status code is used. | | `escapeXml` | Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. | ## StatusCode Bean @@ -134,14 +134,17 @@ or in a Servlet: ```java import net.thauvin.erik.httpstatus.StatusCode; -// --- - -StatusCode statusCode = new StatusCode((Integer) request.getAttribute("javax.servlet.error.status_code")); -if (statusCode.isError()) { - if (statusCode.isServerError()) { - String reason = statusCode.getReason(); - } else { - // ... +public class ExampleServlet extends HttpServlet { + public void doGet(HttpServletRequest request, HttpServletResponse response) { + var statusCode = new StatusCode( + (Integer) request.getAttribute("javax.servlet.error.status_code")); + if (statusCode.isError()) { + if (statusCode.isServerError()) { + var reason = statusCode.getReason(); + } else { + // ... + } + } } } ```