Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Contact the core Jetty developers at
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 from 1 day to full product delivery
Skip to end of metadata
Go to start of metadata
Writing a Custom Handler
The org.mortbay.jetty.Handler interface provides Jetty's core of content generation or manipulation. Classes that call this interface will have the implementation of modifying or handling requests.
Handlers are usually arranged in a list and a request presented to each handler in turn until (or at most) one indicates that the request has been handled. In this situation, this will allow handlers to:
- Ignore requests that are not applicable
- Handle requests by populating the response and/or generating content
- Modify the request but allow it to pass onto the next handler(s). Headers and attributes may be modified or an InputStream filter added
- Modify the response but allow the request to pass onto the next handler(s). Headers may be modified or OutputStream filters added
These are the handlers that implement the org.mortbay.jetty.Handler interface package:
- Abstract Handler - Abstract handler.
- Context Handler - This handler wraps a call to handle by setting the context and servlet path, plus setting the context classloader.
- Error Handler - Handler for error pages. It is registered at the org.mortbay.jetty.handler.ErrorHandler context attributed and called by the HttpResponse.sendError method to write an error page.
- Handler Collection - Handler collection.
- Not Found Handler - Handler for resources that were not found. Implements OPTIONS and TRACE methods for the server.
- Request Log Handler - This handler can be used to wrap an individual context for context logging.
- Wrapped Handler - Handler collection.
To view sample code for Handler class click here