Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] How to prevent ServletHandler$Default404Servlet from being added

Am 27.03.2015 um 14:51 schrieb Lothar Kimmeringer:
> Am 27.03.2015 um 14:45 schrieb Joakim Erdfelt:
>> You are using ServletContextHandler and its various .addServlet() methods, right?
>> You really shouldn't be using ServletHandler directly (that's an internal class
>> for ServletContextHandler)
> 
> I'm calling servletContextHandler.addServlet(servletHolder, pathSpec)
> 
> So the answer is, no?

So is there a way to prevent the default404-servlet from being added?
As far as I can see, I don't use any internal APIs for the adding of
servlets. By looking into ServletHandler I see that there is a method
servletHandler.setEnsureDefaultServlet, that allows to disable that
functionality, but it seems to never been called within Jetty and
setting it for myself would contradict your statement that the class
is internal. When I call getServletHandler before I add a servlet
myself, the result is null. When I call it after adding the servlet,
the default servlet is already added.

I more and more see that as a bug. This feature breaks existing
setups and can't be changed without using internal classes you
discourage using.


Cheers, Lothar


Back to the top