jakartaee / jakartaee/servlet

Proposal: add getCompleteRequestURI() and getCompleteRequestURL()

Open
#462 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement
Dominant language
Java
Stars
325
Forks
112
PR merge metrics
No merged PRs in 30d

Description

Information that is commonly needed from [`HttpServletRequest`](https://docs.oracle.com/javaee/6/api/index.html?javax/servlet/http/HttpServletRequest.html) is the URL or URI in its complete form. But currently, there is no such feature in Servlet, which raises a lot of questions for new developers, as is demonstrated in [this highly voted Stackoverflow question](https://stackoverflow.com/questions/2222238/httpservletrequest-to-complete-url).

The [`request-target`](https://datatracker.ietf.org/doc/html/rfc7230#section-5.3) in the HTTP RFC is the complete URI. URIs are specified in the `origin-form`.
The problem with Servlet is that the Servlet API doesn't provide this vital part of the HTTP request, but strips it down, and then provides parts of it separately. So users have to find [methods ](https://stackoverflow.com/questions/2222238/httpservletrequest-to-complete-url) to reconstruct it again back to it's original form, which can introduce bugs.
Users expect that the existing methods [`getRequestURI()`](https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getRequestURI()) and [`getRequestURL()`](https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getRequestURL()) provide what they are looking for, but then find that their application isn't behaving as expected, and have to resort to the JavaDocs to find out that these methods aren't providing complete information.

These problems would be solved if new methods with names like `getCompleteRequestURI()` or `getFullRequestURI()`, and `getCompleteRequestURL()` or `getFullRequestURL()`, would be added to `HttpServletRequest`.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the HttpServletRequest API documentation and the existing getRequestURI() and getRequestURL() contracts, then read the referenced RFC request-target section. Determine the exact semantics and naming for complete URI and URL methods, including how they differ from the existing methods. Done means the API proposal has resolved these details and the resulting Servlet API change is specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.