Skip to main content

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

When I need to do this, I usually cheat and use urlrewritefilter. I have the servlet serve /index, then rewrite / to /index. With embedded Jetty, I had a few surprises if I didn't use the default servlet for /.

On 6/9/2011 8:34 AM, David Hovemeyer wrote:
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
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top