Version: 9.4.30.v20200611 |

Default Handler
Previous | Chapter 18. Provided Servlets, Filters, and Handlers Home | Next

##### Contact the core Jetty developers at www.webtide.com

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development

## Default Handler

### Info

- Classname: `org.eclipse.jetty.server.handler.DefaultHandler`
- Maven Artifact: org.eclipse.jetty:jetty-server
- Javadoc: http://www.eclipse.org/jetty/javadoc/9.4.30.v20200611/org/eclipse/jetty/server/handler/DefaultHandler.html

### Usage

A simple handler that is useful to terminate handler chains with a clean fashion. As in the example below, if a resource to be served is not matched within the resource handler the `DefaultHandler` will take care of producing a 404 page. This class is a useful template to either extend and embrace or simply provide a similar implementation for customizing to your needs. There is also an Error Handler that services errors related to the servlet api specification, so it is best to not get the two confused.

> ### Note

> The `DefaultHandler` will also handle serving out the `flav.ico` file should a request make it through all of the other handlers without being resolved.

        Server server = new Server(8080);
        HandlerList handlers = new HandlerList();
        ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setBaseResource(Resource.newResource("."));
        handlers.setHandlers(new Handler[]
        { resourceHandler, new DefaultHandler() });
        server.setHandler(handlers);
        server.start();

Previous | Top | Next
Shutdown Handler | Home | Error Handler

See an error or something missing? Contribute to this documentation at Github!(Generated: 2020-06-11)