{"id":37021347,"url":"https://github.com/steinarb/servlet","last_synced_at":"2026-01-14T02:31:06.901Z","repository":{"id":57738150,"uuid":"233467570","full_name":"steinarb/servlet","owner":"steinarb","description":"Various servets and filters","archived":false,"fork":false,"pushed_at":"2025-12-23T10:17:40.000Z","size":267,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-25T00:23:06.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steinarb.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-01-12T22:21:43.000Z","updated_at":"2025-12-23T10:17:44.000Z","dependencies_parsed_at":"2024-12-03T22:21:51.767Z","dependency_job_id":"fb5bb8c8-9b4f-4735-9988-c9669531486e","html_url":"https://github.com/steinarb/servlet","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/steinarb/servlet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinarb%2Fservlet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinarb%2Fservlet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinarb%2Fservlet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinarb%2Fservlet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steinarb","download_url":"https://codeload.github.com/steinarb/servlet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steinarb%2Fservlet/sbom","scorecard":{"id":850911,"data":{"date":"2025-08-11","repo":{"name":"github.com/steinarb/servlet","commit":"65998728fa11f9c259309d0cb23993e35cf798e0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/10 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/servlet-maven-ci-build.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/servlet-maven-ci-build.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/steinarb/servlet/servlet-maven-ci-build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/servlet-maven-ci-build.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/steinarb/servlet/servlet-maven-ci-build.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":1,"reason":"SAST tool is not run on all commits -- score normalized to 1","details":["Warn: 2 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T22:30:43.245Z","repository_id":57738150,"created_at":"2025-08-23T22:30:43.245Z","updated_at":"2025-08-23T22:30:43.245Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T02:31:05.599Z","updated_at":"2026-01-14T02:31:06.889Z","avatar_url":"https://github.com/steinarb.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"* Java servlet common code\n\nServlet and filter classes that are intended to be inherited to cut down on boilerplate code\n\n** Status of the project\n\n[[https://github.com/steinarb/servlet/actions/workflows/servlet-maven-ci-build.yml][file:https://github.com/steinarb/servlet/actions/workflows/servlet-maven-ci-build.yml/badge.svg]]\n[[https://coveralls.io/github/steinarb/servlet][file:https://coveralls.io/repos/github/steinarb/servlet/badge.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=alert_status#.svg]]\n[[https://maven-badges.herokuapp.com/maven-central/no.priv.bang.servlet/servlet][file:https://maven-badges.herokuapp.com/maven-central/no.priv.bang.servlet/servlet/badge.svg]]\n[[https://www.javadoc.io/doc/no.priv.bang.servlet/servlet][file:https://www.javadoc.io/badge/no.priv.bang.servlet/servlet.svg]]\n\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/images/project_badges/sonarcloud-white.svg]]\n\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=sqale_index#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=coverage#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=ncloc#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=code_smells#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=sqale_rating#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=security_rating#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=bugs#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=vulnerabilities#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=duplicated_lines_density#.svg]]\n[[https://sonarcloud.io/summary/new_code?id=steinarb_servlet][file:https://sonarcloud.io/api/project_badges/measure?project=steinarb_servlet\u0026metric=reliability_rating#.svg]]\n\n** Release history\n\n| Date                   | Version | Comment                                                                                   |\n|------------------------+---------+-------------------------------------------------------------------------------------------|\n| \u003c2025-12-23 Tue 11:17\u003e |   3.0.3 | Built with karaf 4.4.9 BOM                                                                |\n| \u003c2025-11-06 Thu 22:58\u003e |   3.0.2 | Use shiro-jaxrs 2.0.6                                                                     |\n| \u003c2025-07-16 Wed 11:11\u003e |   3.0.1 | Use shiro-jaxrs 2.0.5                                                                     |\n| \u003c2025-06-18 Wed 20:04\u003e |   3.0.0 | Use jersey 2.47 and jackson 2.19.1, built for java 21 (reason for major version bump)     |\n| \u003c2025-05-04 Sun 22:42\u003e |   2.0.2 | Use jersey 2.46 and jackson 2.19.0                                                        |\n| \u003c2025-04-23 Wed 21:20\u003e |   2.0.1 | Use shiro-jaxrs 2.0.4                                                                     |\n| \u003c2025-03-02 Sun 18:12\u003e |   2.0.0 | FrontendServlet read exported react router routes, runtime incompatible change            |\n| \u003c2024-12-13 Fri 21:48\u003e |   1.8.1 | use shiro-jaxrs 2.0.2                                                                     |\n| \u003c2024-08-03 Sat 07:51\u003e |   1.8.0 | Change FrontendServlet signature, use jersey 2.44, jackson 2.17.2                         |\n| \u003c2024-05-31 Fri 20:30\u003e |   1.7.0 | use shiro-jaxrs 2.0.1                                                                     |\n| \u003c2024-03-25 Mon 12:36\u003e |  1.6.11 | jersey 2.42, jackson 2.16.2                                                               |\n| \u003c2024-03-01 Fri 17:54\u003e |  1.6.10 | add [[https://shiro.apache.org/jaxrs.html][shiro-jaxrs]] feature to JerseyServlet                                                  |\n| \u003c2023-11-05 Sun 10:37\u003e |   1.6.9 | jersey 2.41, jackson 2.15.3, junit jupiter 5.10.0, mockito 5.7.0, and mockrunner 2.0.7    |\n| \u003c2023-07-30 Sun 14:03\u003e |   1.6.8 | Use jersey-karaf-feature 1.9.6, jersey 2.40 and jackson 2.15.2, built with Java 17        |\n| \u003c2023-04-26 Wed 00:12\u003e |   1.6.7 | Use jersey-karaf-feature 1.9.5 and jackson 2.15.0                                         |\n| \u003c2023-04-24 Mon 19:16\u003e |   1.6.6 | Use jersey-karaf-feature 1.9.4, jersey 2.39.1 and jackson 2.14.2                          |\n| \u003c2023-04-14 Fri 17:08\u003e |   1.6.5 | Set cache-control and expires headers to avoid index.html caching of webapps              |\n| \u003c2023-01-14 Sat 12:47\u003e |   1.6.4 | Add overridable method for reporting not found errors to FrontendServlet                  |\n| \u003c2022-11-28 Mon 21:33\u003e |   1.6.3 | Use jersey 2.37. Use jackson 2.14.1 to fix CVE-2022-42003 and CVE-2022-42004              |\n| \u003c2022-08-10 Wed 21:34\u003e |   1.6.2 | Use jersey 2.36, karaf 4.4.1, maven-bundle-plugin 5.1.8                                   |\n| \u003c2022-06-01 Wed 16:57\u003e |   1.6.1 | Use jackson 2.13.3                                                                        |\n| \u003c2022-05-29 Sun 09:11\u003e |   1.6.0 | Use karaf 4.4.0 and OSGi 8                                                                |\n| \u003c2022-02-20 Sun 00:03\u003e |   1.5.8 | Use jersey 2.35 and jackson 2.13.1                                                        |\n| \u003c2021-06-15 Tue 22:22\u003e |   1.5.7 | Use jersey 2.34 and jackson 2.12.3                                                        |\n| \u003c2021-06-09 Wed 00:27\u003e |   1.5.6 | Avoid inherited imported dependencies leaking out in the servlet BoM                      |\n| \u003c2021-06-01 Tue 00:07\u003e |   1.5.5 | Use karaf 4.3.2 and the osgi.cmpn maven dependency of OSGi 7 compendium                   |\n| \u003c2021-05-02 Sun 17:34\u003e |   1.5.4 | Use a jersey feature version that supports java.time serialization/deserialization        |\n| \u003c2021-04-19 Mon 01:00\u003e |   1.5.3 | Use the OSGi adapters BoM                                                                 |\n| \u003c2021-04-17 Sat 21:34\u003e |   1.5.2 | Provide maven Bill of Materials to simplify usage                                         |\n| \u003c2021-04-15 Thu 20:40\u003e |   1.5.1 | Get maven dependencies and maven plugin config from a parent POM                          |\n| \u003c2021-04-12 Mon 18:10\u003e |   1.5.0 | Built with karaf 4.3.0 and OSGi 7                                                         |\n| \u003c2021-01-24 Sun 21:25\u003e |   1.4.0 | Use jersey 2.33 and jackson 2.12.1                                                        |\n| \u003c2020-09-12 Sat 16:30\u003e |   1.3.2 | Fix [[https://github.com/steinarb/servlet/issues/3][issue #3]] by requiring package from jersey-inject-hk2                                  |\n| \u003c2020-09-11 Fri 22:25\u003e |   1.3.1 | Does not pull in servicemix javax.inject at runtime                                       |\n| \u003c2020-07-31 Fri 13:07\u003e |   1.3.0 | Fix [[https://github.com/steinarb/servlet/issues/2][issue #2]] in FrontendServlet, add content-type for .ico files                          |\n| \u003c2020-07-29 Wed 16:12\u003e |   1.2.0 | Fix [[https://github.com/steinarb/servlet/issues/1][issue #1]] in FrontendServlet                                                           |\n| \u003c2020-04-09 Thu 22:40\u003e |   1.1.3 | Compile and runtime dependencies to jersey 2.30.1, runtime dependencies to jackson 2.10.3 |\n| \u003c2020-03-05 Thu 18:22\u003e |   1.1.2 | Use runtime dependency to jackson-databind 2.9.10.3 to fix security issue CVE-2020-8840   |\n| \u003c2020-02-21 Fri 22:42\u003e |   1.1.1 | Bugfix release of the JerseyServlet with correct method name                              |\n| \u003c2020-02-19 Wed 07:52\u003e |   1.1.0 | First release of the JerseyServlet                                                        |\n| \u003c2020-01-12 Sun 23:26\u003e |   1.0.0 | First release of the FrontendServlet                                                      |\n\n** Overview of the project\n\n*** Frontend\n\nThis is a servlet that's intended to be extended by a servlet serving out a JS frontend packed by webpack.\n\nThe servlet will search for resources matching the pathInfo (minus the webcontext) on the classpath and serve them out, setting the content type based on the file name extension.\n\nThe servlet will try serving the file \"index.html\" (that must exist on the classpath) for a list of routes, that can be set by a subclass. This is to handle reloads of URLs set by e.g. the react router.\n\nTo use the servlet in an application built with maven, add the maven dependency:\n#+begin_src xml\n  \u003cdependency\u003e\n   \u003cgroupId\u003eno.priv.bang.servlet\u003c/groupId\u003e\n   \u003cartifactId\u003eservlet.frontend\u003c/artifactId\u003e\n   \u003cversion\u003e3.0.3\u003c/version\u003e\n  \u003c/dependency\u003e\n#+end_src\n\nTo use the servlet in a webapp running in the apache karaf web whiteboard apache:\n 1. Import the Bill of Materials (BoM) into the project's dependencyManagement\n    #+begin_src xml\n      \u003cbuild\u003e\n       \u003cdependencyManagement\u003e\n        \u003cdependencies\u003e\n         \u003cdependency\u003e\n          \u003cgroupId\u003eno.priv.bang.servlet\u003c/groupId\u003e\n          \u003cartifactId\u003eservlet-bom\u003c/artifactId\u003e\n          \u003cversion\u003e3.0.3\u003c/version\u003e\n          \u003ctype\u003epom\u003c/type\u003e\n          \u003cscope\u003eimport\u003c/scope\u003e\n         \u003c/dependency\u003e\n        \u003c/dependencies\u003e\n       \u003c/dependencyManagement\u003e\n      \u003c/build\u003e\n    #+end_src\n 2. Create a maven project building an OSGi bundle, and add the following maven dependencies to the project (the version of the dependencies, is provided by the BoM import)\n    #+begin_src xml\n      \u003cbuild\u003e\n       \u003cdependencies\u003e\n        \u003cdependency\u003e\n         \u003cgroupId\u003eno.priv.bang.servlet\u003c/groupId\u003e\n         \u003cartifactId\u003eservlet.frontend\u003c/artifactId\u003e\n         \u003cscope\u003eprovided\u003c/scope\u003e\n        \u003c/dependency\u003e\n        \u003cdependency\u003e\n         \u003cgroupId\u003eno.priv.bang.servlet\u003c/groupId\u003e\n         \u003cartifactId\u003eservlet.frontend\u003c/artifactId\u003e\n         \u003ctype\u003exml\u003c/type\u003e\n         \u003cclassifier\u003efeatures\u003c/classifier\u003e\n        \u003c/dependency\u003e\n       \u003c/dependencies\u003e\n      \u003c/build\u003e\n    #+end_src\n    The \u003cprovided\u003e scope dependency provides compile time dependency for the bundle, and the xml classifier dependencies pulls the karaf runtime dependency of the sevlet into the feature for the OSGi bundle project\n 3. In the OSGi bundle project, add a DS component registering with the web whiteboard\n    #+begin_src java\n      @Component(service={Servlet.class}, property={\"alias=/myapp\"})\n      public class ReactServlet extends FrontendServlet {\n          public ReactServlet() {\n              super();\n              setRoutes(\"/\", \"/counter\", \"/about\");\n          }\n\n          @Reference\n          public void setLogservice(LogService logservice) {\n              super.setLogService(logservice);\n          }\n      }\n    #+end_src\n\n**** Processing content\n\nIn many cases, just sending resources found on the classpath, is what is wanted.\n\nBut in some cases it may be desirable to do processing on the resource found on the classpath, before it is returned.\n\nOne such example, is the \"index.html\" file that is used to boostrap the webapp returned by the FrontendServlet.  In this case it is desirable to set [[https://ogp.me][Open Graph \u003cmeta\u003e headers]] corresponding to the path the application is entered with.\n\nThis is so that you can give an URL to a specific subpage in a webapp, and that URL will return \u003cmeta\u003e headers with information that will make the URL look nice in google searches and various social media.\n\nTo accomplish this, FrontendServlet has two overridable methods:\n#+begin_src java\n  public class FrontendServlet extends HttpServlet{\n      protected boolean thisIsAResourceThatShouldBeProcessed(String pathInfo, String resource, String contentType);\n      protected void processResource(HttpServletResponse response, String pathInfo, String resource, String contentType) throws IOException;\n  }\n#+end_src\n\nThe =thisIsAResourceThatShouldBeProcessed()= method is overridden to detect if a resource should be processed.  If this method returns true, then =processResource()= will be called and no further handling of the request will be done by the FrontendServlet base class.\n\nThe FrontendServlet base implementation of =processResource()= returns the status code [[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/501][501 Not Implemented]].\n\n*** Jersey\n\nThis is a servlet that's intended to be extended by a servlet using [[https://jersey.github.io/][jersey]] to implement a REST API.\n\nThe JerseyServlet does three things:\n 1. Adds a way to add injected OSGi services to the HK2 dependency injection container, so that the OSGi services can be injected into Jersey resources, allowing the Jersey resources to be thin shims over OSGi service calls\n 2. Adds the subpackage \".resources\" of the servlet's package as the default package to scan for Jersey resources /Note/! If a different package is set by configuration, this will override the default\n 3. Adds the [[https://shiro.apache.org/jaxrs.html][shiro-jaxrs ShiroFeature]], which:\n    1. configures exception mapping from Shiro’s AuthorizationException to HTTP status codes (401 and 403)\n    2. exposes Shiro’s Subject as a java.security.Principal (Principal Propagation)\n    3. Configures processing of Shiro’s annotations, which makes it easy to control access to JAX-RS resources by [[https://shiro.apache.org/jaxrs.html#example][using annotations to require login, roles and permissions]]\n\nTo use the servlet in an application built with maven, add the maven dependency:\n#+begin_src xml\n  \u003cdependency\u003e\n   \u003cgroupId\u003eno.priv.bang.servlet\u003c/groupId\u003e\n   \u003cartifactId\u003eservlet.jersey\u003c/artifactId\u003e\n   \u003cversion\u003e3.0.3\u003c/version\u003e\n  \u003c/dependency\u003e\n#+end_src\n\nTo use the servlet in a webapp running in the apache karaf web whiteboard apache:\n 1. Import the Bill of Materials (BoM) into the project's dependencyManagement\n    #+begin_src xml\n      \u003cbuild\u003e\n       \u003cdependencyManagement\u003e\n        \u003cdependencies\u003e\n         \u003cdependency\u003e\n          \u003cgroupId\u003eno.priv.bang.servlet\u003c/groupId\u003e\n          \u003cartifactId\u003eservlet-bom\u003c/artifactId\u003e\n          \u003cversion\u003e1.8.1\u003c/version\u003e\n          \u003ctype\u003epom\u003c/type\u003e\n          \u003cscope\u003eimport\u003c/scope\u003e\n         \u003c/dependency\u003e\n        \u003c/dependencies\u003e\n       \u003c/dependencyManagement\u003e\n      \u003c/build\u003e\n    #+end_src\n 2. Create a maven project building an OSGi bundle, and add the following maven dependencies to the project (the version of the dependencies, is provided by the BoM import)\n    #+begin_src xml\n      \u003cbuild\u003e\n       \u003cdependencies\u003e\n        \u003cdependency\u003e\n         \u003cgroupId\u003eno.priv.bang.servlet\u003c/groupId\u003e\n         \u003cartifactId\u003eservlet.jersey\u003c/artifactId\u003e\n         \u003cscope\u003eprovided\u003c/scope\u003e\n        \u003c/dependency\u003e\n        \u003cdependency\u003e\n         \u003cgroupId\u003eno.priv.bang.servlet\u003c/groupId\u003e\n         \u003cartifactId\u003eservlet.jersey\u003c/artifactId\u003e\n         \u003ctype\u003epom\u003c/type\u003e\n         \u003cscope\u003eimport\u003c/scope\u003e\n        \u003c/dependency\u003e\n       \u003c/dependencies\u003e\n      \u003c/build\u003e\n    #+end_src\n    The \u003cprovided\u003e scope dependency provides compile time dependency for the bundle, and the xml classifier dependencies pulls the karaf runtime dependency of the sevlet into the feature for the OSGi bundle project\n 3. In the OSGi bundle project, add a DS component registering with the web whiteboard.\n    #+begin_src java\n      package no.priv.bang.servlet.jersey.test;\n\n      @Component(service={Servlet.class})\n      public class ExampleJerseyServlet extends JerseyServlet {\n\n          @Reference\n          public void setHelloService(HelloService service) {\n              addInjectedOsgiService(HelloService.class, service);\n          }\n\n          @Reference\n          public void setLogService(LogService logservice) {\n              super.setLogService(logservice);\n          }\n      }\n    #+end_src\n    /Note/! [[http://javadox.com/org.osgi/osgi.cmpn/6.0.0/org/osgi/service/log/LogService.html][The OSGi LogService]] must be added by a separate method, since the LogService is used by the JerseyServlet itself (as well as being added to HK2, which makes it possible to use LogService in Jersey resources).\n 4. Add resources implementing REST API endpoints in the .resources sub-package of the servlet's package, and use @Inject to inject the OSGi services that JerseyServlet adds to the HK2 dependency injection container:\n    #+begin_src java\n      package no.priv.bang.servlet.jersey.test.resources;\n\n      @Path(\"/hello\")\n      public class HelloResource {\n\n          @Inject\n          HelloService service;\n\n          @GET\n          @Produces(\"text/plain\")\n          public String getHello() {\n              return service.hello();\n          }\n      }\n    #+end_src\n\n** License\n\nThis code is licensed under the Apache license v. 2.  See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteinarb%2Fservlet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteinarb%2Fservlet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteinarb%2Fservlet/lists"}