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

Request.getContext().getContextPath() #10294

Closed
cowwoc opened this issue Aug 10, 2023 · 5 comments
Closed

Request.getContext().getContextPath() #10294

cowwoc opened this issue Aug 10, 2023 · 5 comments
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@cowwoc
Copy link
Contributor

cowwoc commented Aug 10, 2023

Jetty version(s)
12.0.0

Java version/vendor (use: java -version)
20

OS type/version
Microsoft Windows [Version 10.0.19045.3324]

Description
When I invoke Request.getContextPath(Request) I get back null. The Javadoc does not indicate that the return value may be null and it's not clear what this indicates. Does this imply a context path of "/"? If so, why not return "/"?

@cowwoc cowwoc added the Bug For general bugs on Jetty side label Aug 10, 2023
@lachlan-roberts
Copy link
Contributor

A return of null would mean that you are in a handler not wrapped by a ContextHandler.

The default value returned by ContextHandler.ScopedContext#getContextPath is "/".
But if you are not in a context you will instead get the ServerContext which will return null for getContextPath().

@cowwoc
Copy link
Contributor Author

cowwoc commented Aug 11, 2023

Got it. Mentioning this behavior in the method(s)` Javadoc would resolve it for me.

@gregw
Copy link
Contributor

gregw commented Aug 11, 2023

Got it. Mentioning this behavior in the method(s)` Javadoc would resolve it for me.
@cowwoc will do. The core handler API in jetty 12 is new in 12 and very much under documented, so feedback like this is most welcome.

gregw added a commit that referenced this issue Aug 11, 2023
Fix #10294 Improve getContextPath javadoc
gregw added a commit that referenced this issue Aug 11, 2023
Fix #10294 Improve getContextPath javadoc
gregw added a commit that referenced this issue Aug 11, 2023
Fix #10294 Improve getContextPath javadoc
@gregw
Copy link
Contributor

gregw commented Aug 11, 2023

@cowwoc see #10297

gregw added a commit that referenced this issue Aug 11, 2023
trying to be less informative???
gregw added a commit that referenced this issue Aug 20, 2023
Fix #10294 Improve getContextPath javadoc
@gregw
Copy link
Contributor

gregw commented Aug 20, 2023

fixed with #10297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

3 participants