diff --git a/.github_changelog_generator b/.github_changelog_generator
index 073fac8..19e45d2 100644
--- a/.github_changelog_generator
+++ b/.github_changelog_generator
@@ -1 +1 @@
-future-release=1.0.6
+future-release=1.1.0
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 61a9130..fb7f4a8 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
A simple JSP Tag Library to display the code, reason, cause and/or message for HTTP status codes in JSP error pages.
+ +A simple JSP +Tag Library to display the code, reason, cause and/or message for HTTP +status codes in JSP error pages.
For example:
-<%@ page isErrorPage="true" %>
-<%@ taglib prefix="hs" uri="http://erik.thauvin.net/taglibs/httpstatus" %>
-
- <html><head><hs:code/> <hs:reason default="Server Error"/></title>
- <title>
- </head><hs:reason default="Server Error"/></h1>
- <h1><hs:cause default="Unable to complete your request."/></pre>
- Cause: <pre><hs:message default="A server error has occured."/></pre>
- Message: <pre> ...
<%@ page isErrorPage="true" %>
+<%@ taglib prefix="hs" uri="http://erik.thauvin.net/taglibs/httpstatus" %>
+
+ <html><head><hs:code/> <hs:reason default="Server Error"/></title>
+ <title>
+ </head><hs:reason default="Server Error"/></h1>
+ <h1><hs:cause default="Unable to complete your request."/></pre>
+ Cause: <pre><hs:message default="A server error has occured."/></pre>
+ Message: <pre> ...
or
-<%@ page isErrorPage="true" import="net.thauvin.erik.httpstatus.Reasons" %>
-<%= Reasons.getReasonPhrase(pageContext.getErrorData().getStatusCode()) %>
would display on a 501 status code:
-Not Implemented
-
-<%@ page isErrorPage="true" import="net.thauvin.erik.httpstatus.Reasons" %>
+<%= Reasons.getReasonPhrase(pageContext.getErrorData().getStatusCode()) %>
would display on a 501 +status code:
+Not Implemented
+Include the following in your build.gradle
file:
dependencies {
- implementation 'net.thauvin.erik.httpstatus:httpstatus:1.0.6'
-}
-
+{
+ dependencies 'net.thauvin.erik.httpstatus:httpstatus:1.1.0'
+ implementation }
or as a Maven artifact:
-<dependency>
-<groupId>net.thauvin.erik.httpstatus</groupId>
- <artifactId>httpstatus</artifactId>
- <version>1.0.6</version>
- </dependency>
dependency>
+ <groupId>net.thauvin.erik.httpstatus</groupId>
+ <artifactId>httpstatus</artifactId>
+ <version>1.1.0</version>
+ <dependency> </
The <hs:cause/>
tag displays the cause of current HTTP status code, if any. A shorthand for:
<%= pageContext.getErrorData().getThrowable().getCause().getLocalizedMessage() %>
The <hs:cause/>
tag displays the cause of current
+HTTP status code, if any. A shorthand for:
<%= pageContext.getErrorData().getThrowable().getCause().getLocalizedMessage() %>
Optional attributes are:
escapeXml |
-Converts <, >, &, ', " to their corresponding entity codes. Value is true by default. |
+Converts <, >, &, ', " to their corresponding entity codes.
+Value is true by default. |
The <hs:code/>
tag displays the current HTTP status code, if any. A shorthand for:
<%= pageContext.getErrorData().getStatusCode() %>
The <hs:code/>
tag displays the current HTTP
+status code, if any. A shorthand for:
<%= pageContext.getErrorData().getStatusCode() %>
The <hs:message/>
tag displays the current error message, if any. A shorthand for:
<%= request.getAttribute("javax.servlet.error.message") %>
The <hs:message/>
tag displays the current error
+message, if any. A shorthand for:
<%= request.getAttribute("javax.servlet.error.message") %>
Optional attributes are:
escapeXml |
-Converts <, >, &, ', " to their corresponding entity codes. Value is true by default. |
+Converts <, >, &, ', " to their corresponding entity codes.
+Value is true by default. |
The <hs:reason/>
tag displays the reason for a HTTP status code, if any. Optional attributes are:
The <hs:reason/>
tag displays the reason for a
+HTTP status code, if any. Optional attributes are:
code |
-The HTTP status error code. If not specified the current status code is used. | +The HTTP status error code. If not specified the current status code +is used. |
default |
@@ -178,38 +229,43 @@
||
escapeXml |
-Converts <, >, &, ', " to their corresponding entity codes. Value is true by default. |
+Converts <, >, &, ', " to their corresponding entity codes.
+Value is true by default. |
The StatusCode
bean can be used to check the class of the status code error. For example, using the JSTL:
<%@ taglib prefix="hs" uri="http://erik.thauvin.net/taglibs/httpstatus" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-
-<jsp:useBean id="statusCode" class="net.thauvin.erik.httpstatus.StatusCode"/>
-<c:set target="${statusCode}" property="code"><hs:code/></c:set>
-<c:choose>
-<c:when test="${statusCode.isClientError()}">
- <hs:reason/>)
- An error occurred on your side. (</c:when>
- <c:otherwise>
- <hs:message/>)
- An error occurred on our side. (</c:otherwise>
- </c:choose>
The StatusCode
bean can be used to check the class of
+the status code error. For example, using the JSTL:
<%@ taglib prefix="hs" uri="http://erik.thauvin.net/taglibs/httpstatus" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+<jsp:useBean id="statusCode" class="net.thauvin.erik.httpstatus.StatusCode"/>
+<c:set target="${statusCode}" property="code"><hs:code/></c:set>
+<c:choose>
+<c:when test="${statusCode.isClientError()}">
+ <hs:reason/>)
+ An error occurred on your side. (</c:when>
+ <c:otherwise>
+ <hs:message/>)
+ An error occurred on our side. (</c:otherwise>
+ </c:choose>
or in a Servlet:
-import net.thauvin.erik.httpstatus.StatusCode;
-
-// ---
-
-new StatusCode((Integer) request.getAttribute("javax.servlet.error.status_code"));
- StatusCode statusCode = if (statusCode.isError()) {
-if (statusCode.isServerError()) {
- String reason = statusCode.getReason();
- else {
- } // ...
-
- } }
import net.thauvin.erik.httpstatus.StatusCode;
+
+// ---
+
+= new StatusCode((Integer) request.getAttribute("javax.servlet.error.status_code"));
+ StatusCode statusCode if (statusCode.isError()) {
+if (statusCode.isServerError()) {
+ String reason = statusCode.getReason();
+ } else {
+ // ...
+ }
+ }
The StatusCode
bean methods are:
getReason |
-Returns the reason for the status code (eg: Internal Server Error ) |
+Returns the reason for the status code (eg:
+Internal Server Error ) |
isClientError |
@@ -254,7 +311,9 @@
The reasons are defined in a ResourceBundle properties as follows:
+The reasons are defined in a ResourceBundle +properties as follows:
You can query the reason phrase for status codes as follows:
-java -jar httpstatus-1.0.6.jar 404 500
- $ 404: Not Found
-500: Internal Server Error
$ java -jar httpstatus-1.1.0.jar 404 500
+404: Not Found
+500: Internal Server Error
If no status code is specified, all will be printed:
-java -jar httpstatus-1.0.6.jar
- $ 100: Continue
-101: Switching Protocols
-102: Processing
-103: Early Hints
-200: OK
-201: Created
-202: Accepted
-203: Non-Authoritative Information
-204: No Content
-205: Reset Content
-206: Partial Content
-207: Multi-Status
-208: Already Reported
-226: IM Used
-...
$ java -jar httpstatus-1.1.0.jar
+100: Continue
+101: Switching Protocols
+102: Processing
+103: Early Hints
+200: OK
+201: Created
+202: Accepted
+203: Non-Authoritative Information
+204: No Content
+205: Reset Content
+206: Partial Content
+207: Multi-Status
+208: Already Reported
+226: IM Used
+...