{"id":20741126,"url":"https://github.com/robtimus/servlet-utils","last_synced_at":"2025-12-24T23:02:28.562Z","repository":{"id":57722450,"uuid":"391636808","full_name":"robtimus/servlet-utils","owner":"robtimus","description":"Provides utility classes for working with servlets","archived":false,"fork":false,"pushed_at":"2024-10-15T11:49:39.000Z","size":1051,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-18T01:45:20.399Z","etag":null,"topics":["java","servlet","servlets"],"latest_commit_sha":null,"homepage":"https://robtimus.github.io/servlet-utils/","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/robtimus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2021-08-01T13:37:18.000Z","updated_at":"2024-10-15T11:49:37.000Z","dependencies_parsed_at":"2023-02-15T18:16:03.996Z","dependency_job_id":"3fef02be-39bb-4075-ab69-28c6c6c41b74","html_url":"https://github.com/robtimus/servlet-utils","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fservlet-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fservlet-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fservlet-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robtimus%2Fservlet-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robtimus","download_url":"https://codeload.github.com/robtimus/servlet-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243030805,"owners_count":20224666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["java","servlet","servlets"],"created_at":"2024-11-17T06:33:59.939Z","updated_at":"2025-12-24T23:02:28.555Z","avatar_url":"https://github.com/robtimus.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# servlet-utils\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.robtimus/servlet-utils)](https://search.maven.org/artifact/com.github.robtimus/servlet-utils)\n[![Build Status](https://github.com/robtimus/servlet-utils/actions/workflows/build.yml/badge.svg)](https://github.com/robtimus/servlet-utils/actions/workflows/build.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.github.robtimus%3Aservlet-utils\u0026metric=alert_status)](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Aservlet-utils)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.github.robtimus%3Aservlet-utils\u0026metric=coverage)](https://sonarcloud.io/summary/overall?id=com.github.robtimus%3Aservlet-utils)\n[![Known Vulnerabilities](https://snyk.io/test/github/robtimus/servlet-utils/badge.svg)](https://snyk.io/test/github/robtimus/servlet-utils)\n\nProvides utility classes for working with servlets. Below are some examples; for a full list, see the [API](https://robtimus.github.io/servlet-utils/apidocs/).\n\n## Init parameter reading\n\nPackage [com.github.robtimus.servlet.parameters](https://robtimus.github.io/servlet-utils/apidocs/com.github.robtimus.servlet/com/github/robtimus/servlet/parameters/package-summary.html) contains several classes that make it easy to read init parameters. For instance, to read an int init parameter that cannot be negative:\n\n```java\nrequestLimit = IntParameter.of(config, \"requestLimit\")\n        .atLeast(0)\n        .valueWithDefault(Integer.MAX_VALUE);\n```\n\n## Transforming input/output\n\nSometimes it's necessary to transform the input and/or output. Class [ServletUtils](https://robtimus.github.io/servlet-utils/apidocs/com.github.robtimus.servlet/com/github/robtimus/servlet/ServletUtils.html) contains methods to transform a `ServletInputStream`, `ServletOutputStream`, `BufferedReader` or `PrintWriter`, as retrieved from a `ServletRequest` or `ServletResponse`.\n\nIn addition, classes [InputTransformingHttpServletRequestWrapper](https://robtimus.github.io/servlet-utils/apidocs/com.github.robtimus.servlet/com/github/robtimus/servlet/http/InputTransformingHttpServletRequestWrapper.html) and [OutputTransformingHttpServletResponseWrapper](https://robtimus.github.io/servlet-utils/apidocs/com.github.robtimus.servlet/com/github/robtimus/servlet/http/OutputTransformingHttpServletResponseWrapper.html) make it easy to wrap an `HttpServletRequest` or `HttpServletResponse` with transforming input or output. Simply override the necessary `transform` method to provide the actual transformation.\n\n## Cookie reading\n\nClass [CookieUtils](https://robtimus.github.io/servlet-utils/apidocs/com.github.robtimus.servlet/com/github/robtimus/servlet/http/CookieUtils.html) contains methods to read cookies as optionals and streams.\n\n## Asynchronous support for try-finally\n\nMethod [AsyncUtils.doFilter](https://robtimus.github.io/servlet-utils/apidocs/com.github.robtimus.servlet/com/github/robtimus/servlet/AsyncUtils.html#doFilter-javax.servlet.ServletRequest-javax.servlet.ServletResponse-javax.servlet.FilterChain-com.github.robtimus.servlet.ServletConsumer-) can be used as a replacement for a try-finally block that also works with asynchronous request handling.\n\nThe following only works for non-asynchronous request handling; for asynchronous request handling the code in the `finally` block is often executed too early.\n\n```java\ntry {\n    chain.doFilter(request, response);\n} finally {\n    doSomething(request, response);\n}\n```\n\nThe following works both with asynchronous and non-asynchronous request handling.\n\n```java\nAsyncUtils.doFilter(request, response, chain, (req, res) -\u003e {\n    doSomething(req, res);\n});\n```\n\n## Body capturing filter\n\nClass [BodyCapturingFilter](https://robtimus.github.io/servlet-utils/apidocs/com.github.robtimus.servlet/com/github/robtimus/servlet/http/BodyCapturingFilter.html) can be used as base class for a filter that captures the request and response bodies. It captures the request body while it body is read, and provides callback methods to perform the necessary logic when the request body is read or when the response body is written. See its documentation for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fservlet-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobtimus%2Fservlet-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobtimus%2Fservlet-utils/lists"}