Yes, I know is weird. Nevertheless, I have to argue why it should not be done. And I have found nothing in the servlet specification.
Chapter 4. Servlet Context
4.1. Introduction to the ServletContext Interface
The ServletContext interface defines a servlet’s view of the web application within which the servlet is
running.
…
A ServletContext is rooted at a known path within a web server. For example, a servlet context could
be located at http://example.com/catalog. All requests that begin with the /catalog request path, known as the context path, are routed to the web application associated with the ServletContext.
…
The configuration and the code are not so easy to post.
But the most important thing is that I have a class that extends org.eclipse.jetty.ee10.webapp.WebAppContext and is added as Jetty handler.
Inside this class that extends WebAppContext I call in the constructor
super(null, servletContextPath)
where the “servletContextPath” is the one containing a space.
Afterward, I call in the same context class:
ServletHolder servletHolder = new ServletHolder(VaadinServlet.class);
addServlet(servletHolder, "/*");
LocationUtil.verifyRelativePath() doesn’t complain about basic cases that include a space. Could you put a breakpoint in the method to see what the input is to that method when it throws?
Yeah but it’s not the space that makes it break. "/myapp/" without a space leads to the same result. So the question then is what gets passed to the method in the cases where it does work?
Context Path: The path prefix associated with the ServletContext that this
servlet is a part of. If this context is the “default” context rooted at the base of the
Web server’s URL name space, this path will be an empty string. Otherwise, if the
context is not rooted at the root of the server’s name space, the path starts with a
/ character but does not end with a / character
the path starts with a
/ character but does not end with a / character
Do you mean that request.getPathInfo() returns /my app/? This does not sound correct to me. getPathInfo() is not supposed to contain the context path nor the servlet path segments
This is most likely where the error comes from. The input to verifyRelativePath is LocationUtil.ensureRelativeNonNull(request.getPathInfo()); ensureRelativeNonNull basically only handles null and removes the leading slash if present. So my guess was that /my app/ comes from request.getPathInfo().
But maybe the caller is not that one; above code is from BootstrapHandler class. Could you verify who is calling LocationUtil.verifyRelativePath() when the failure happens?