diff --git a/.idea/misc.xml b/.idea/misc.xml index 05fa3d9..9963c9f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,6 +4,7 @@ + diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a59454..0e632d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,27 @@ # Changelog -## [1.0.5](https://github.com/ethauvin/HttpStatus/tree/1.0.5) (2021-03-20) +## [1.1.0](https://github.com/ethauvin/httpstatus/tree/1.1.0) (2023-09-29) -[Full Changelog](https://github.com/ethauvin/HttpStatus/compare/1.0.4...1.0.5) +[Full Changelog](https://github.com/ethauvin/httpstatus/compare/1.0.5...1.1.0) + +**Implemented enhancements:** + +- Move to Jakarta EE [\#7](https://github.com/ethauvin/HttpStatus/issues/7) +- Only use XML character entities in Utils.escapeXml\(\) [\#6](https://github.com/ethauvin/HttpStatus/issues/6) +- Implement a StatusCode bean to check the status code. [\#5](https://github.com/ethauvin/HttpStatus/issues/5) + +## [1.0.5](https://github.com/ethauvin/httpstatus/tree/1.0.5) (2021-03-20) + +[Full Changelog](https://github.com/ethauvin/httpstatus/compare/1.0.4...1.0.5) **Implemented enhancements:** - Retrieve the error message from the request, if available. [\#4](https://github.com/ethauvin/HttpStatus/issues/4) - Add Unofficial Codes [\#3](https://github.com/ethauvin/HttpStatus/issues/3) -## [1.0.4](https://github.com/ethauvin/HttpStatus/tree/1.0.4) (2019-05-08) +## [1.0.4](https://github.com/ethauvin/httpstatus/tree/1.0.4) (2019-05-08) -[Full Changelog](https://github.com/ethauvin/HttpStatus/compare/1.0.3...1.0.4) +[Full Changelog](https://github.com/ethauvin/httpstatus/compare/1.0.3...1.0.4) **Implemented enhancements:** @@ -21,21 +31,21 @@ - hs:reason always outputs the default value. [\#2](https://github.com/ethauvin/HttpStatus/issues/2) -## [1.0.3](https://github.com/ethauvin/HttpStatus/tree/1.0.3) (2016-01-22) +## [1.0.3](https://github.com/ethauvin/httpstatus/tree/1.0.3) (2016-01-22) -[Full Changelog](https://github.com/ethauvin/HttpStatus/compare/1.0.2...1.0.3) +[Full Changelog](https://github.com/ethauvin/httpstatus/compare/1.0.2...1.0.3) -## [1.0.2](https://github.com/ethauvin/HttpStatus/tree/1.0.2) (2016-01-21) +## [1.0.2](https://github.com/ethauvin/httpstatus/tree/1.0.2) (2016-01-21) -[Full Changelog](https://github.com/ethauvin/HttpStatus/compare/1.0.1...1.0.2) +[Full Changelog](https://github.com/ethauvin/httpstatus/compare/1.0.1...1.0.2) -## [1.0.1](https://github.com/ethauvin/HttpStatus/tree/1.0.1) (2015-12-16) +## [1.0.1](https://github.com/ethauvin/httpstatus/tree/1.0.1) (2015-12-16) -[Full Changelog](https://github.com/ethauvin/HttpStatus/compare/1.0...1.0.1) +[Full Changelog](https://github.com/ethauvin/httpstatus/compare/1.0...1.0.1) -## [1.0](https://github.com/ethauvin/HttpStatus/tree/1.0) (2015-12-04) +## [1.0](https://github.com/ethauvin/httpstatus/tree/1.0) (2015-12-04) -[Full Changelog](https://github.com/ethauvin/HttpStatus/compare/ad982eff1b27c31b54df4abae00ac2d4065543d6...1.0) +[Full Changelog](https://github.com/ethauvin/httpstatus/compare/ad982eff1b27c31b54df4abae00ac2d4065543d6...1.0) diff --git a/README.md b/README.md index b844171..28f6eaa 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -# HttpStatus JSP Tag Library +# HttpStatus JSP Tag Library [](http://opensource.org/licenses/BSD-3-Clause) [](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) [](https://rife2.com/bld) [](https://github.com/ethauvin/httpstatus/releases/latest) -[](https://search.maven.org/search?q=g:%22net.thauvin.erik.httpstatus%22%20AND%20a:%22httpstatus%22) -[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/httpstatus/httpstatus/) +[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/httpstatus/httpstatus/) +[](https://central.sonatype.com/artifact/net.thauvin.erik.httpstatus/httpstatus) + [](https://snyk.io/test/github/ethauvin/httpstatus?targetFile=pom.xml) [](https://sonarcloud.io/summary/new_code?id=ethauvin_HttpStatus) [](https://github.com/ethauvin/httpstatus/actions/workflows/bld.yml) [](https://circleci.com/gh/ethauvin/HttpStatus/tree/master) - A simple [JSP](http://www.oracle.com/technetwork/java/javaee/jsp/index.html) Tag Library to display the [code](#hscode), [reason](#hsreason), [cause](#hscode) and/or [message](#hsmessage) for [HTTP status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) in JSP error pages. For example: @@ -35,11 +35,14 @@ or <%= Reasons.getReasonPhrase(pageContext.getErrorData().getStatusCode()) %> ``` -would display on a [501 status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.2): +would display on a [501 status code](https://www.rfc-editor.org/rfc/rfc9110.html#name-501-not-implemented): - Not Implemented +```plain +Not Implemented +``` + +## Usage with [Gradle](https://gradle.org/), [Maven](http://maven.apache.org/) or [bld](https://rife2.com/bld) -## Usage with [Gradle](https://gradle.org/) or [Maven](http://maven.apache.org/) Include the following in your `build.gradle` file: ```gradle @@ -48,20 +51,28 @@ repositories { } dependencies { - implementation 'net.thauvin.erik.httpstatus:httpstatus:1.0.5' + implementation 'net.thauvin.erik.httpstatus:httpstatus:1.1.0' } ``` -or as a Maven artifact: +or as a `Maven` artifact: ```xml net.thauvin.erik.httpstatus httpstatus - 1.0.5 + 1.1.0 ``` +or in a `bld` build file: + +```java +scope(compile).include( + dependency("net.thauvin.erik.httpstatus","httpstatus", version(1, 1, 0)) +); +``` + ## hs:cause The `` tag displays the cause of current HTTP status code, if any. A shorthand for: @@ -78,6 +89,7 @@ Optional attributes are: | `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: ```jsp @@ -261,6 +273,7 @@ The reasons are defined in a [ResourceBundle](https://docs.oracle.com/en/java/ja | `599` | Network Connect Timeout Error | ## Command Line Usage + You can query the reason phrase for status codes as follows: ```sh diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 6786d8e..a508afe 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -1,7 +1,7 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.2 -bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.0 -bld.repositories=RIFE2_SNAPSHOTS,RIFE2_RELEASES,MAVEN_CENTRAL +bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.1-SNAPSHOT +bld.repositories=MAVEN_LOCAL, RIFE2_SNAPSHOTS,RIFE2_RELEASES,MAVEN_CENTRAL bld.downloadLocation= bld.version=1.7.2 diff --git a/pom.xml b/pom.xml index 9a3ab33..22b2d96 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ httpstatus 1.1.0-SNAPSHOT HttpStatus - HttpStatus JSP Tag Library + Tag library to display the code, reason, cause and/or message for HTTP status codes in JSP error pages https://github.com/ethauvin/HttpStatus diff --git a/src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java b/src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java index 04f598f..32c24d9 100644 --- a/src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java +++ b/src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java @@ -42,6 +42,7 @@ import rife.tools.exceptions.FileUtilsErrorException; import java.io.IOException; import java.nio.file.Path; import java.util.List; +import java.util.jar.Attributes; import static rife.bld.dependencies.Repository.*; import static rife.bld.dependencies.Scope.compile; @@ -54,7 +55,7 @@ public class HttpStatusBuild extends Project { name = "HttpStatus"; version = version(1, 1, 0, "SNAPSHOT"); - var description = "HttpStatus JSP Tag Library"; + var description = "Tag library to display the code, reason, cause and/or message for HTTP status codes in JSP error pages"; var url = "https://github.com/ethauvin/HttpStatus"; mainClass = "net.thauvin.erik.httpstatus.Reasons"; @@ -69,10 +70,12 @@ public class HttpStatusBuild extends Project { .include(dependency("jakarta.servlet.jsp", "jakarta.servlet.jsp-api", version(3, 1, 1))) .include(dependency("jakarta.el", "jakarta.el-api", version(5, 0, 1))); scope(test) - .include(dependency("org.assertj", "assertj-joda-time", version(2, 2, 0))) + .include(dependency("org.assertj", "assertj-core", version(3, 24, 2))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 0))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 0))); + jarOperation().manifestAttribute(Attributes.Name.MAIN_CLASS, pkg + '.' + "Reasons"); + javadocOperation().javadocOptions() .docTitle(description + ' ' + version.toString()) .docLint(NO_MISSING) @@ -83,7 +86,6 @@ public class HttpStatusBuild extends Project { .withCredentials(property("sonatype.user"), property("sonatype.password")) : repository(SONATYPE_RELEASES.location()) .withCredentials(property("sonatype.user"), property("sonatype.password"))) - .repository(MAVEN_LOCAL) .info(new PublishInfo() .groupId(pkg) .artifactId(name.toLowerCase()) @@ -138,4 +140,4 @@ public class HttpStatusBuild extends Project { PomBuilder.generateInto(publishOperation().info(), publishOperation().dependencies(), Path.of(workDirectory.getPath(), "pom.xml").toFile()); } -} \ No newline at end of file +} diff --git a/src/main/java/net/thauvin/erik/httpstatus/StatusCode.java b/src/main/java/net/thauvin/erik/httpstatus/StatusCode.java index 98c751e..1982200 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/StatusCode.java +++ b/src/main/java/net/thauvin/erik/httpstatus/StatusCode.java @@ -39,6 +39,7 @@ import java.io.Serializable; * The StatusCode bean implements methods to check the class of an HTTP status code. * * @author Erik C. Thauvin + * @since 1.1.0 */ public class StatusCode implements Serializable { @Serial diff --git a/src/main/java/net/thauvin/erik/httpstatus/Utils.java b/src/main/java/net/thauvin/erik/httpstatus/Utils.java index 062c69e..35422f3 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/Utils.java +++ b/src/main/java/net/thauvin/erik/httpstatus/Utils.java @@ -43,7 +43,6 @@ import java.io.Writer; * @since 1.0 */ public final class Utils { - /** * Disables the default constructor. * diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java index 6fc2801..5fec8d7 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java @@ -57,6 +57,7 @@ public abstract class XmlSupport extends SimpleTagSupport { * * @param defaultValue The default value. */ + @SuppressWarnings("unused") public void setDefault(final String defaultValue) { this.defaultValue = defaultValue; } @@ -66,6 +67,7 @@ public abstract class XmlSupport extends SimpleTagSupport { * * @param escapeXml true or false */ + @SuppressWarnings("unused") public void setEscapeXml(final boolean escapeXml) { this.escapeXml = escapeXml; } diff --git a/src/main/resources/META-INF/httpstatus.tld b/src/main/resources/META-INF/httpstatus.tld index 272763c..0766792 100644 --- a/src/main/resources/META-INF/httpstatus.tld +++ b/src/main/resources/META-INF/httpstatus.tld @@ -37,7 +37,7 @@ HttpStatus JSP Tag Library HttpStatus JSP Tags - 1.0.5 + 1.1.0 hs http://erik.thauvin.net/taglibs/httpstatus diff --git a/src/main/resources/net/thauvin/erik/httpstatus/reasons.properties b/src/main/resources/net/thauvin/erik/httpstatus/reasons.properties index 916bc49..c690ea9 100644 --- a/src/main/resources/net/thauvin/erik/httpstatus/reasons.properties +++ b/src/main/resources/net/thauvin/erik/httpstatus/reasons.properties @@ -1,35 +1,3 @@ -# -# reasons.properties -# -# Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net) -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# Neither the name of this project nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - 100=Continue 101=Switching Protocols 102=Processing diff --git a/src/test/java/net/thauvin/erik/httpstatus/CauseTagTest.java b/src/test/java/net/thauvin/erik/httpstatus/CauseTagTest.java index 0e10df2..a71958b 100644 --- a/src/test/java/net/thauvin/erik/httpstatus/CauseTagTest.java +++ b/src/test/java/net/thauvin/erik/httpstatus/CauseTagTest.java @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; * Implements the CauseTagTest class. * * @author Erik C. Thauvin - * @since 1.0 + * @since 1.1.0 */ class CauseTagTest { @Test diff --git a/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java b/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java index 90288a6..f60c957 100644 --- a/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java +++ b/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java @@ -38,7 +38,6 @@ import java.util.ResourceBundle; import static org.assertj.core.api.Assertions.assertThat; - /** * Reasons Tests. * diff --git a/src/test/java/net/thauvin/erik/httpstatus/StatusCodeTest.java b/src/test/java/net/thauvin/erik/httpstatus/StatusCodeTest.java index 9eb2f8a..7ecd692 100644 --- a/src/test/java/net/thauvin/erik/httpstatus/StatusCodeTest.java +++ b/src/test/java/net/thauvin/erik/httpstatus/StatusCodeTest.java @@ -42,6 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat; * StatusCode Tests. * * @author Erik C. Thauvin + * @since 1.1.0 */ class StatusCodeTest { @Test diff --git a/src/test/java/net/thauvin/erik/httpstatus/UtilsTest.java b/src/test/java/net/thauvin/erik/httpstatus/UtilsTest.java index d941f07..53f974b 100644 --- a/src/test/java/net/thauvin/erik/httpstatus/UtilsTest.java +++ b/src/test/java/net/thauvin/erik/httpstatus/UtilsTest.java @@ -39,7 +39,6 @@ import java.io.StringWriter; import static org.assertj.core.api.Assertions.assertThat; - /** * Utils Tests. *
StatusCode
true
false