# Jetty Configuration Overview

> Jetty has been design with flexible deployment options. It has been decoupled from any utility libraries so that it does not require it's own configuration files or system and only the handler required for a particular site need to be included, so a server can be as efficient or as powerful as required. Configuration Decoupling While the Jetty Server has a configuration file, it is only a one of the ways to configure Jetty. Regardless of the merits of the actual configuration file format and package used, the main problem for developers is that any WWW server configuration files are in addition to those that they may wish to use for their own applications and often impose location restrictions on the runtime. Thus configuration for Jetty has been abstracted to a Java interface, of which multiple implementations can be developed. An implementation of the interface com.mortbay.HTTP.HttpConfiguration must be passed to the constructor of com.mortbay.HTTP.HttpServer in order to configure a Jetty server. The implementation of HttpConfiguration may: Read configuration information from a custom file or database. Read configuration information from a config file format of another Servlet server (e.g. Jeeves). Hard code a specific configuration. Parameterize a particular subset of configurations Map some other configuration mechanism. Several HttpConfiguration implementations are included with the Jetty distribution: com.mortbay.HTTP.Configure.SimpleServletConfig provides a simple configuration where a single servlet may be configured and served from command line options. com.mortbay.HTTP.Configure.FileServer configures a HTTP server to serve files from the current directory. com.mortbay.Jetty.Server is configuration that can be added to under program control, or configured from a Java properties file. com.mortbay.Jetty.Demo is a specific instance of com.mortbay.Jetty.Server. Handler Stacks The functionality of Jetty is provided by the combination of individual HttpHandler instances that are arranged in stacks of handlers. The main task of configuring Jetty is to configure individual handlers and then arrange them in stacks for particular request paths. Current Handlers implemented by Jetty include: Log Handler - Writes request log files. Parameter Handler - Move form content and cookies into request parameters. Session Handler - Maintain session and browser Id's and session data. Authentication handler - Handle basic name and password authentication. Translate Handler - Translate request paths. Filter Handler - Insert filters into responses for tag handling, encryption etc. Servlet Handler - Dispatch servlet requests File Handler - Handle file requests. Forward Handler - Forwarded requests to other servers. Proxy Handler - Act as a HTTP Proxy server NotFound Handler - Generate the Not Found response A simple configuration of Jetty may match any request path starting with "/" to a stack of: ParamHandler - To move form and cookie values to the request parameters. ServletHandler - To service any requests for servlets. FileHandler - To service any requests for files or directories. NotFoundHandler - To reject any requests not handled by a servlet or a file. Exception Stacks Exception handler stacks can be configured in a similar fashion to HttpHandlers. However, for HttpConfigurations extended from the NullConfiguration class, a default exceptionHandler is provided that simply formats any exception as part of the response.