Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] HttpServletRequest.getPathInfo() inconsistent behavior

When I put a webapp in /webapps/mycontext and have a web.xml specify a servlet that responds to "/":

<servlet-name>myservlet</servlet-name>
<url-pattern>/</url-pattern>

HttpServletRequest.getPathInfo() returns the correct part of the URL:

http://foo.com/mycontext/blah

.getPathInfo() -> "/blah"

When I mount the servlet programmatically, though, getPathInfo() returns null.

ServletContextHandler s = new ServletContextHandler();
s.setContextPath("/mycontext");
s.addServlet(MyServlet.class, "/");

.getPathInfo() -> null

Is there a way that I can get the part of the URL after /mycontext consistently, regardless of whether my servlet is mounted in web.xml or programmatically?



Back to the top