Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify behaviour of HttpServletMapping.getMatchValue() #316

Closed
lachlan-roberts opened this issue May 7, 2020 · 1 comment · Fixed by #497
Closed

Clarify behaviour of HttpServletMapping.getMatchValue() #316

lachlan-roberts opened this issue May 7, 2020 · 1 comment · Fixed by #497
Assignees
Milestone

Comments

@lachlan-roberts
Copy link

The javadoc for HttpServletMapping.getMatchValue() says

If the getMappingMatch value is CONTEXT_ROOT or DEFAULT, this method must return the empty string. If the getMappingMatch value is EXACT, this method must return the portion of the path that matched the servlet, omitting any leading slash. If the getMappingMatch value is EXTENSION or PATH, this method must return the value that matched the '*'.

It says the leading slash should be omitted for EXACT matches, but it does not say that for EXTENSION or PATH. So if we had an EXTENSION mapping *.ts and had a request at /a.ts, then the javadoc seems to indicate that the leading slash should be included as it matched the '*'.

There is TCK test com/sun/ts/tests/servlet/api/javax_servlet_http/httpservletrequest40/Client.java#httpServletMappingTest2 which tests that the leading slash was not included and we get a matchValue of just a.

If the TCK has the correct behaviour I think the javadoc should be more clear about when the leading slash is omitted for matchValue.

@arjantijms arjantijms added this to the 6.0 milestone May 3, 2021
@arjantijms arjantijms self-assigned this May 3, 2021
@arjantijms
Copy link
Contributor

Good point. There's a table in the javadoc that clearly doesn't show the leading slash, but this should be in the javadoc as well. Let's clarify this for Servlet 6.0.

markt-asf added a commit to markt-asf/servlet-api that referenced this issue Jan 20, 2023
Add more examples, remove unnecessary text and be explicit about removal
of leading '/'.
markt-asf added a commit to markt-asf/servlet-api that referenced this issue Jan 20, 2023
Add more examples, remove unnecessary text and be explicit about removal
of leading '/'.
markt-asf added a commit that referenced this issue Jan 27, 2023
Add more examples, remove unnecessary text and be explicit about removal
of leading '/'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants