diff --git a/README.html b/README.html new file mode 100644 index 0000000..8e742df --- /dev/null +++ b/README.html @@ -0,0 +1,450 @@ + + + + + + + + + + + + +

HttpStatus JSP Tag Library

+

A simple JSP Tag Library to display the code, reason and/or cause 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>
+<title><hs:code/> <hs:reason default="Server Error"/></title>
+</head>
+<h1><hs:reason default="Server Error"/></h1>
+Cause: <pre><hs:cause default="Unable to complete your request."/></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
+
+

hs:cause

+

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:

+ ++++ + + + + + + + + + + + + + + + + +
AttributeDescription
defaultThe fallback value to output, if no cause is available.
escapeXmlConverts <,>,&,'," to their corresponding entity codes. Value is true by default.
+

hs:code

+

The <hs:code/> tag displays the current HTTP status code, if any. A shorthand for:

+
<%= pageContext.getErrorData().getStatusCode() %>
+

hs:reason

+

The <hs:reason/> tag displays the reason for a HTTP status code, if any. Optional attributes are:

+ ++++ + + + + + + + + + + + + + + + + + + + + +
AttributeDescription
codeThe HTTP status error code. If not specified the current status code is used.
defaultThe fallback value to output, if no reason is available.
escapeXmlConverts <,>,&,'," to their corresponding entity codes. Value is true by default.
+

The reasons are defined in a ResourceBundle properties as follows:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Status CodeReason
100Continue
101Switching Protocols
102Processing
200OK
201Created
202Accepted
203Non-Authoritative Information
204No Content
205Reset Content
206Partial Content
207Multi-Status
208Already Reported
226IM Used
300Multiple Choices
301Moved Permanently
302Moved Temporarily
303See Other
304Not Modified
305Use Proxy
306Switch Proxy
307Temporary Redirect
308Permanent Redirect
400Bad Request
401Unauthorized
402Payment Required
403Forbidden
404Not Found
405Method Not Allowed
406Not Acceptable
407Proxy Authentication Required
408Request Timeout
409Conflict
410Gone
411Length Required
412Precondition Failed
413Request Entity Too Large
414Request-URI Too Long
415Unsupported Media Type
416Requested Range Not Satisfiable
417Expectation Failed
418I'm A Teapot
419Insufficient Space on Resource
420Method Failure
421Misdirected Request
422Unprocessable Entity
423Locked
424Failed Dependency
426Upgrade Required
428Precondition Required
429Too Many Requests
431Request Header Fields Too Large
440Login Timeout
444No Response
449Retry With
450Blocked by Windows Parental Controls
451Unavailable For Legal Reasons
494Request Header Too Large
495Cert Error
496No Cert
497HTTP to HTTPS
498Token Expired/Invalid
499Client Closed Request
500Internal Server Error
501Not Implemented
502Bad Gateway
503Service Unavailable
504Gateway Timeout
505HTTP Version Not Supported
506Variant Also Negotiates
507Insufficient Storage
508Loop Detected
509Bandwidth Limit Exceeded
510Not Extended
511Network Authentication Required
520Unknown Error
522Origin Connection Time-out
598Network Read Timeout Error
599Network Connect Timeout Error
+ + diff --git a/README.md b/README.md index 7e6d876..037608b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # HttpStatus JSP Tag Library -A simple JSP Tag Library to display the reason of [HTTP status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) in JSP error pages. +A simple JSP Tag Library to display the [code](#hscode), [reason](#hsreason) and/or [cause](#hscode) for [HTTP status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) in JSP error pages. ---- @@ -43,7 +43,7 @@ Optional attributes are: Attribute | Description ----------- | ------------------------------------------------------------------------------------------- `default` | The fallback value to output, if no cause is available. -`escapeXml` | Converts <,>,&,'," to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is true by default. +`escapeXml` | Converts <,>,&,'," to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. ## hs:code The `` tag displays the current HTTP status code, if any. A shorthand for: @@ -60,7 +60,7 @@ Attribute | Description ----------- | ------------------------------------------------------------------------------------------- `code` | The HTTP status error code. If not specified the current status code is used. `default` | The fallback value to output, if no reason is available. -`escapeXml` | Converts <,>,&,'," to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is true by default. +`escapeXml` | Converts <,>,&,'," to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. The reasons are defined in a [ResourceBundle](http://docs.oracle.com/javase/8/docs/api/java/util/ResourceBundle.html) properties as follows: diff --git a/build.gradle b/build.gradle index 56c327b..3e8e027 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,8 @@ apply plugin: 'java' apply plugin: 'idea' apply plugin: 'application' +import org.apache.tools.ant.taskdefs.condition.Os + defaultTasks 'deploy' version = '1.0' @@ -45,7 +47,7 @@ jar { def props = new Properties() file(buildProps).withInputStream { stream -> props.load(stream) } version = version + '.' + props.get(buildProp) - archiveName = archiveName.toLowerCase() + archiveName = archiveName.toLowerCase() manifest.attributes('Main-Class': mainClassName) } @@ -78,7 +80,24 @@ task deploy(dependsOn: ['build', 'copyToDeploy']) { mustRunAfter clean } -task release(dependsOn: ['deploy', 'wrapper']) { +task release(dependsOn: ['deploy', 'pandoc', 'wrapper']) { group = "Publishing" description = "Releases new version." -} \ No newline at end of file +} + +task pandoc(type: Exec) { + group = "Documentation" + def pandoc_cmd = 'pandoc --from markdown_github --to html5 -s -o README.html README.md'; + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine 'cmd', '/c', pandoc_cmd + } + else { + commandLine pandoc_cmd + } + standardOutput = new ByteArrayOutputStream() + ext.output = { + return standardOutput.toString() + } +} + + \ No newline at end of file