From 7dc9a51a7fd9486e64cfcf0ba0a3d8bb8456f69e Mon Sep 17 00:00:00 2001
From: "Erik C. Thauvin"
Date: Fri, 25 Mar 2022 11:50:32 -0700
Subject: [PATCH] Updated dependencies.
---
.circleci/config.yml | 74 +++--
.github/workflows/gradle.yml | 2 +-
.idea/.name | 1 +
.idea/HttpStatus.iml | 9 -
.idea/compiler.xml | 6 +
.idea/inspectionProfiles/Project_Default.xml | 7 +-
.idea/jarRepositories.xml | 30 ++
.idea/misc.xml | 2 +
.idea/modules.xml | 8 -
.idea/vcs.xml | 1 +
appveyor.yml | 2 +-
build.gradle | 32 +-
docs/README.html | 299 ++++++++++++-------
gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 59821 bytes
gradle/wrapper/gradle-wrapper.properties | 2 +-
gradlew | 269 ++++++++++-------
16 files changed, 449 insertions(+), 295 deletions(-)
create mode 100644 .idea/.name
delete mode 100644 .idea/HttpStatus.iml
create mode 100644 .idea/compiler.xml
create mode 100644 .idea/jarRepositories.xml
delete mode 100644 .idea/modules.xml
diff --git a/.circleci/config.yml b/.circleci/config.yml
index be10f4a..d873524 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,37 +1,55 @@
version: 2
-jobs:
- build:
- docker:
- - image: circleci/openjdk:8-jdk
+defaults: &defaults
+ working_directory: ~/repo
+ environment:
+ JVM_OPTS: -Xmx3200m
+ TERM: dumb
+ CI_NAME: "CircleCI"
- working_directory: ~/repo
-
- environment:
- JVM_OPTS: -Xmx3200m
- TERM: dumb
-
- steps:
- - checkout
- - restore_cache:
- keys:
+defaults_gradle: &defaults_gradle
+ steps:
+ - checkout
+ - restore_cache:
+ keys:
- gradle-dependencies-{{ checksum "build.gradle" }}
# fallback to using the latest cache if no exact match is found
- gradle-dependencies-
+ - run:
+ name: Gradle Dependencies
+ command: ./gradlew dependencies
+ - save_cache:
+ paths:
+ - ~/.m2
+ key: gradle-dependencies-{{ checksum "build.gradle" }}
+ - run:
+ name: Run All Checks
+ command: ./gradlew check
+ - store_artifacts:
+ path: build/reports/
+ destination: reports
+ - store_test_results:
+ path: build/reports/
- - run:
- name: Gradle Dependencies
- command: ./gradlew dependencies
+jobs:
+ build_gradle_jdk17:
+ <<: *defaults
- - save_cache:
- paths: ~/.m2
- key: gradle-dependencies-{{ checksum "build.gradle" }}
+ docker:
+ - image: cimg/openjdk:17.0
- - run:
- name: Run All Checks
- command: ./gradlew check
+ <<: *defaults_gradle
- - store_artifacts:
- path: build/reports/
- destination: reports
- - store_test_results:
- path: build/reports/
+ build_gradle_jdk8:
+ <<: *defaults
+
+ docker:
+ - image: circleci/openjdk:8-jdk
+
+ <<: *defaults_gradle
+
+workflows:
+ version: 2
+ gradle:
+ jobs:
+ - build_gradle_jdk8
+ - build_gradle_jdk17
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 251e704..86d7e7f 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
- java-version: [ 1.8, 11, 15 ]
+ java-version: [ 1.8, 11, 17, 18 ]
steps:
- uses: actions/checkout@v2
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..6bf8b6f
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+httpstatus
\ No newline at end of file
diff --git a/.idea/HttpStatus.iml b/.idea/HttpStatus.iml
deleted file mode 100644
index d6ebd48..0000000
--- a/.idea/HttpStatus.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..61a9130
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 78c3966..63787bb 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -2,7 +2,6 @@
-
@@ -47,13 +46,9 @@
+
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..4e9cedf
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 28a804d..9d92aa6 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,8 @@
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 4c575ac..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..49e611e 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
index f858073..877b3ed 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -23,7 +23,7 @@ cache:
environment:
matrix:
- - JAVA_HOME: C:\Program Files\Java\jdk15
+ - JAVA_HOME: C:\Program Files\Java\jdk17
- JAVA_HOME: C:\Program Files\Java\jdk11
matrix:
diff --git a/build.gradle b/build.gradle
index 4746236..eea5bf9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,4 @@
plugins {
- id 'checkstyle'
id 'java'
id 'jacoco'
id 'idea'
@@ -7,10 +6,10 @@ plugins {
id 'maven-publish'
id 'signing'
id 'pmd'
- id 'com.github.ben-manes.versions' version '0.38.0'
+ id 'com.github.ben-manes.versions' version '0.42.0'
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
- id 'com.github.spotbugs' version '4.7.1'
- id 'org.sonarqube' version '3.2.0'
+ id 'com.github.spotbugs' version '5.0.6'
+ id 'org.sonarqube' version '3.3'
}
import com.github.spotbugs.snom.SpotBugsTask
@@ -35,20 +34,20 @@ mainClassName = 'net.thauvin.erik.httpstatus.Reasons'
ext {
versions = [
pmd: '6.35.0',
- spotbugs: '4.2.3'
+ spotbugs: '4.6.0'
]
}
repositories {
mavenLocal()
mavenCentral()
+ maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
- implementation 'javax.servlet:javax.servlet-api:4.0.1'
- implementation 'javax.servlet.jsp:jsp-api:2.2.1-b03'
- implementation 'javax.el:javax.el-api:3.0.1-b06'
-
+ compileOnly 'javax.servlet:javax.servlet-api:4.0.1'
+ compileOnly 'javax.servlet.jsp:jsp-api:2.2.1-b03'
+ compileOnly 'javax.el:javax.el-api:3.0.1-b06'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
spotbugsPlugins 'com.mebigfatguy.sb-contrib:sb-contrib:7.4.7'
@@ -56,7 +55,7 @@ dependencies {
compileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs"
testCompileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs"
- testImplementation 'org.testng:testng:7.4.0'
+ testImplementation 'org.testng:testng:7.5'
}
tasks.withType(JavaCompile) {
@@ -114,13 +113,6 @@ pmd {
consoleOutput = true
}
-tasks.withType(Checkstyle) {
- reports {
- xml.enabled = false
- html.enabled = true
- }
-}
-
tasks.withType(SpotBugsTask) {
reports {
xml.enabled = false
@@ -223,9 +215,13 @@ task pandoc(type: Exec) {
}
}
+jacoco {
+ toolVersion = '0.8.8-SNAPSHOT'
+}
+
jacocoTestReport {
reports {
- xml.enabled true
+ xml.required = true
}
}
diff --git a/docs/README.html b/docs/README.html
index c024860..4afcd01 100644
--- a/docs/README.html
+++ b/docs/README.html
@@ -5,74 +5,75 @@
HttpStatus JSP Tag Library
-
-
@@ -83,24 +84,36 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni

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>
+<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>
+Message: <pre><hs:message default="A server error has occured."/></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
+
+Include the following in your build.gradle
file:
+dependencies {
+ implementation 'net.thauvin.erik.httpstatus:httpstatus:1.0.6'
+}
+
+or as a Maven artifact:
+<dependency>
+ <groupId>net.thauvin.erik.httpstatus</groupId>
+ <artifactId>httpstatus</artifactId>
+ <version>1.0.6</version>
+</dependency>
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:
@@ -122,10 +135,10 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
hs:code
The <hs:code/>
tag displays the current HTTP status code, if any. A shorthand for:
-
+<%= pageContext.getErrorData().getStatusCode() %>
hs:message
The <hs:message/>
tag displays the current error message, if any. A shorthand for:
-
+<%= request.getAttribute("javax.servlet.error.message") %>
Optional attributes are:
@@ -169,6 +182,78 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
+StatusCode Bean
+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()}">
+ An error occurred on your side. (<hs:reason/>)
+ </c:when>
+ <c:otherwise>
+ An error occurred on our side. (<hs:message/>)
+ </c:otherwise>
+</c:choose>
+or in a Servlet:
+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 {
+ // ...
+ }
+}
+The StatusCode
bean methods are:
+
+
+
+
+
+
+getReason |
+Returns the reason for the status code (eg: Internal Server Error ) |
+
+
+isClientError |
+Checks if the status code is a client error. |
+
+
+isError |
+Checks if the status code is a server or client error. |
+
+
+isInfo |
+Checks if the status code is informational. |
+
+
+isRedirect |
+Checks if the status code is a redirect. |
+
+
+isServerError |
+Checks if the status code is a server error. |
+
+
+isSuccess |
+Checks if the status code is a success. (OK ) |
+
+
+isValid |
+Checks if the status code is valid. |
+
+
+
+Reasons
The reasons are defined in a ResourceBundle properties as follows:
@@ -544,39 +629,27 @@ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warni
-
-Include the following in your build.gradle
file:
-dependencies {
- implementation 'net.thauvin.erik.httpstatus:httpstatus:1.0.6'
-}
-
-or as a Maven artifact:
-
Command Line Usage
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
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
+...