Closed KyleAure closed 2 years ago
The Jakarta EE specs defer to section 12.2 (11.2 in older versions) of the Servlet spec to define valid URL patterns.
You can't remove the leading /
from a URL pattern intended to match a request path for several (spec documented) reasons.
"/"
and ""
have different meanings. See section 12.2. If you remove the leading /
these two patterns cannot be distinguished./
from a URL then, by the rules of section 12.2, the URL pattern becomes an exact match. Because all incoming paths start with /
(see section 12.1) the URL pattern would never match the defined pattern making the definition rather pointless.Given that a URL pattern could be intended for extension mapping or context root mapping, it is not the case that all URL patterns must start with /
.
I would argue that the current language in section 12 of the Servlet spec is sufficiently clear as to how requests are mapped to servlets and that the obvious implication is that URL patterns that are intended to match to paths must start with /
.
@markt-asf Thank you so much for the quick response. It looks like I missing section 12.2 on my search through the spec. Leaving a link here to the section you mentioned in case anyone from the concurrency spec follows up on the mailing list: https://github.com/jakartaee/servlet/blob/master/spec/src/main/asciidoc/servlet-spec-body.adoc#specification-of-mappings
This is part of a discussion taking place on the Concurrency mailing list. https://www.eclipse.org/lists/cu-dev/msg00192.html
When porting the concurrency TCK from the platform to standalone I had removed the leading slash from the urlPatterns within the
@WebServlet
annotations. This was not an intentional change but raised some flags with some of the implementations that have tried running this TCK. As it is today, there does not seem to be any documentation requiring the use of a leading slash. However, all known example usage of@WebSerlvet
does have a leading lash. I.E. https://github.com/jakartaee/servlet/blob/master/spec/src/main/asciidoc/servlet-spec-body.adoc#811-webservletDoes the specification have a requirement to have a leading slash that I did not find? If not, I think the spec needs to make an explicit statement on whether or not the leading slash is required.