## org.mortbay.jetty.servlet
Class DefaultServlet

    java.lang.Object
      javax.servlet.GenericServlet
          javax.servlet.http.HttpServlet
              org.mortbay.jetty.servlet.DefaultServlet

All Implemented Interfaces:
  java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, ResourceFactory

    public class DefaultServlet

extends javax.servlet.http.HttpServlet
implements ResourceFactory

The default servlet. This servlet, normally mapped to /, provides the handling for static content, OPTION and TRACE methods for the context. The following initParameters are supported, these can be set either on the servlet itself or as ServletContext initParameters with a prefix of org.mortbay.jetty.servlet.Default. :

       acceptRanges     If true, range requests and responses are
                        supported

       dirAllowed       If true, directory listings are returned if no
                        welcome file is found. Else 403 Forbidden.

       welcomeServlets  If true, attempt to dispatch to welcome files
                        that are servlets, but only after no matching static
                        resources could be found.

                        This must be false if you want directory listings,
                        but have index.jsp in your welcome file list.

       redirectWelcome  If true, welcome files are redirected rather than
                        forwarded to.

       gzip             If set to true, then static content will be served as
                        gzip content encoded if a matching resource is
                        found ending with ".gz"

      resourceBase      Set to replace the context resource base

      relativeResourceBase
                        Set with a pathname relative to the base of the
                        servlet context root. Useful for only serving static content out
                        of only specific subdirectories.

      aliases           If True, aliases of resources are allowed (eg. symbolic
                        links and caps variations). May bypass security constraints.

      maxCacheSize      The maximum total size of the cache or 0 for no cache.
      maxCachedFileSize The maximum size of a file to cache
      maxCachedFiles    The maximum number of files to cache
      cacheType         Set to "bio", "nio" or "both" to determine the type resource cache.
                        A bio cached buffer may be used by nio but is not as efficient as an
                        nio buffer.  An nio cached buffer may not be used by bio.

      useFileMappedBuffer
                        If set to true, it will use mapped file buffer to serve static content
                        when using NIO connector. Setting this value to false means that
                        a direct buffer will be used instead of a mapped file buffer.
                        By default, this is set to true.

      cacheControl      If set, all static content will have this value set as the cache-control
                        header.

Author:
  Greg Wilkins (gregw), Nigel Canonizado
See Also:
  Serialized Form

Constructor Summary
`DefaultServlet()`

Method Summary
`void` `destroy()`
`protected void` `doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)`
`protected void` `doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)`
`protected void` `doTrace(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)`
`java.lang.String` `getInitParameter(java.lang.String name)`
`Resource` `getResource(java.lang.String pathInContext)` get Resource to serve.
`void` `init()`
`protected boolean` `passConditionalHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Resource resource, HttpContent content)`
`protected void` `sendData(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean include, Resource resource, HttpContent content, java.util.Enumeration reqRanges)`
`protected void` `sendDirectory(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Resource resource, boolean parent)`
`protected void` `writeHeaders(javax.servlet.http.HttpServletResponse response, HttpContent content, long count)`
`protected void` `writeOptionHeaders(HttpFields fields)`
`protected void` `writeOptionHeaders(javax.servlet.http.HttpServletResponse response)`

Methods inherited from class javax.servlet.http.HttpServlet
`doDelete, doHead, doOptions, doPut, getLastModified, service, service`

Methods inherited from class javax.servlet.GenericServlet
`getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultServlet

    public DefaultServlet()

Method Detail

### init

    public void init()
              throws javax.servlet.UnavailableException

  Overrides:
    `init` in class `javax.servlet.GenericServlet`
  Throws:
    `javax.servlet.UnavailableException`

### getInitParameter

    public java.lang.String getInitParameter(java.lang.String name)

  Specified by:
    `getInitParameter` in interface `javax.servlet.ServletConfig`
  Overrides:
    `getInitParameter` in class `javax.servlet.GenericServlet`

### getResource

    public Resource getResource(java.lang.String pathInContext)

  get Resource to serve. Map a path to a resource. The default implementation calls HttpContext.getResource but derived servlets may provide their own mapping.

  Specified by:
    `getResource` in interface `ResourceFactory`
  Parameters:
    `pathInContext` - The path to find a resource for.
  Returns:
    The resource to serve.

### doGet

    protected void doGet(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
                  throws javax.servlet.ServletException,
                         java.io.IOException

  Overrides:
    `doGet` in class `javax.servlet.http.HttpServlet`
  Throws:
    `javax.servlet.ServletException`
    `java.io.IOException`

### doPost

    protected void doPost(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws javax.servlet.ServletException,
                          java.io.IOException

  Overrides:
    `doPost` in class `javax.servlet.http.HttpServlet`
  Throws:
    `javax.servlet.ServletException`
    `java.io.IOException`

### doTrace

    protected void doTrace(javax.servlet.http.HttpServletRequest req,
                           javax.servlet.http.HttpServletResponse resp)
                    throws javax.servlet.ServletException,
                           java.io.IOException

  Overrides:
    `doTrace` in class `javax.servlet.http.HttpServlet`
  Throws:
    `javax.servlet.ServletException`
    `java.io.IOException`

### passConditionalHeaders

    protected boolean passConditionalHeaders(javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response,
                                             Resource resource,
                                             HttpContent content)
                                      throws java.io.IOException

  Throws:
    `java.io.IOException`

### sendDirectory

    protected void sendDirectory(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 Resource resource,
                                 boolean parent)
                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### sendData

    protected void sendData(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            boolean include,
                            Resource resource,
                            HttpContent content,
                            java.util.Enumeration reqRanges)
                     throws java.io.IOException

  Throws:
    `java.io.IOException`

### writeHeaders

    protected void writeHeaders(javax.servlet.http.HttpServletResponse response,
                                HttpContent content,
                                long count)
                         throws java.io.IOException

  Throws:
    `java.io.IOException`

### writeOptionHeaders

    protected void writeOptionHeaders(HttpFields fields)
                               throws java.io.IOException

  Throws:
    `java.io.IOException`

### writeOptionHeaders

    protected void writeOptionHeaders(javax.servlet.http.HttpServletResponse response)
                               throws java.io.IOException

  Throws:
    `java.io.IOException`

### destroy

    public void destroy()

  Specified by:
    `destroy` in interface `javax.servlet.Servlet`
  Overrides:
    `destroy` in class `javax.servlet.GenericServlet`

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.