org.eclipse.jetty.servlet
Class DefaultServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.eclipse.jetty.servlet.DefaultServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig, ResourceFactory

public class DefaultServlet
extends 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.eclipse.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. If false, then a welcome
                    file must exist on disk. If "exact", then exact
                    servlet matches are supported without an existing file.
                    Default is true.

                    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

  resourceCache     If set, this is a context attribute name, which the servlet 
                    will use to look for a shared ResourceCache instance. 
                        
  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.

  pathInfoOnly      If true, only the path info will be applied to the resourceBase 
                        
  stylesheet          Set with the location of an optional stylesheet that will be used
                    to decorate the directory listing html.

  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

  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.


 

See Also:
Serialized Form

Constructor Summary
DefaultServlet()
           
 
Method Summary
 void destroy()
           
protected  void doGet(HttpServletRequest request, HttpServletResponse response)
           
protected  void doOptions(HttpServletRequest req, HttpServletResponse resp)
           
protected  void doPost(HttpServletRequest request, HttpServletResponse response)
           
protected  void doTrace(HttpServletRequest req, HttpServletResponse resp)
           
 String getInitParameter(String name)
           
 Resource getResource(String pathInContext)
          get Resource to serve.
 void init()
           
protected  boolean passConditionalHeaders(HttpServletRequest request, HttpServletResponse response, Resource resource, HttpContent content)
           
protected  void sendData(HttpServletRequest request, HttpServletResponse response, boolean include, Resource resource, HttpContent content, Enumeration reqRanges)
           
protected  void sendDirectory(HttpServletRequest request, HttpServletResponse response, Resource resource, String pathInContext)
           
protected  void writeHeaders(HttpServletResponse response, HttpContent content, long count)
           
protected  void writeOptionHeaders(HttpFields fields)
           
protected  void writeOptionHeaders(HttpServletResponse response)
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, 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 UnavailableException
Overrides:
init in class GenericServlet
Throws:
UnavailableException

getInitParameter

public String getInitParameter(String name)
Specified by:
getInitParameter in interface ServletConfig
Overrides:
getInitParameter in class GenericServlet

getResource

public Resource getResource(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(HttpServletRequest request,
                     HttpServletResponse response)
              throws ServletException,
                     IOException
Overrides:
doGet in class HttpServlet
Throws:
ServletException
IOException

doPost

protected void doPost(HttpServletRequest request,
                      HttpServletResponse response)
               throws ServletException,
                      IOException
Overrides:
doPost in class HttpServlet
Throws:
ServletException
IOException

doTrace

protected void doTrace(HttpServletRequest req,
                       HttpServletResponse resp)
                throws ServletException,
                       IOException
Overrides:
doTrace in class HttpServlet
Throws:
ServletException
IOException

doOptions

protected void doOptions(HttpServletRequest req,
                         HttpServletResponse resp)
                  throws ServletException,
                         IOException
Overrides:
doOptions in class HttpServlet
Throws:
ServletException
IOException

passConditionalHeaders

protected boolean passConditionalHeaders(HttpServletRequest request,
                                         HttpServletResponse response,
                                         Resource resource,
                                         HttpContent content)
                                  throws IOException
Throws:
IOException

sendDirectory

protected void sendDirectory(HttpServletRequest request,
                             HttpServletResponse response,
                             Resource resource,
                             String pathInContext)
                      throws IOException
Throws:
IOException

sendData

protected void sendData(HttpServletRequest request,
                        HttpServletResponse response,
                        boolean include,
                        Resource resource,
                        HttpContent content,
                        Enumeration reqRanges)
                 throws IOException
Throws:
IOException

writeHeaders

protected void writeHeaders(HttpServletResponse response,
                            HttpContent content,
                            long count)
                     throws IOException
Throws:
IOException

writeOptionHeaders

protected void writeOptionHeaders(HttpFields fields)
                           throws IOException
Throws:
IOException

writeOptionHeaders

protected void writeOptionHeaders(HttpServletResponse response)
                           throws IOException
Throws:
IOException

destroy

public void destroy()
Specified by:
destroy in interface Servlet
Overrides:
destroy in class GenericServlet


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