Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Want servlet to serve ONLY root URL

Apologies if this is a dumb question.

I am developing a web app using embedded Jetty (7.4.1 hightide).
There is a single ServletContextHandler with a context path "/",
to which a number of servlets are added.

I would like to add a servlet so that it handles all requests to the
path "/", i.e., the root URL.  However, using "/" as a path spec
causes the servlet to handle ALL requests that aren't explicitly
matched by another servlet.  I.e.,

	ServletContextHandler servletContext =
		new ServletContextHandler(ServletContextHandler.SESSIONS);
	servletContext.setContextPath("/");
	servletContext.addServlet(new ServletHolder(new ServletA()), "/");
	servletContext.addServlet(new ServletHolder(new ServletB()), "/someOtherPath");

In the above example, ServletA will serve all URLs except those matching
"/someOtherPath".  I would like it to only serve the root URL ("/").

Any ideas appreciated.

Thanks,
Dave


Back to the top