org.mortbay.jetty.servlet

Class Default

Implemented Interfaces:
java.io.Serializable, Servlet, ServletConfig

public class Default
extends HttpServlet

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:
 
 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.
 
 putAllowed If true, the PUT method is allowed
 
 delAllowed If true, the DELETE method is allowed
 
 redirectWelcome If true, welcome files are redirected rather than forwarded to.
 
 minGzipLength If set to a positive integer, then static content larger than this 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.
 
 
The MOVE method is allowed if PUT and DELETE are allowed
Version:
$Id: Default.java,v 1.50 2006/01/04 13:55:31 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
Serialized Form

Method Summary

protected Resource
getResource(String pathInContext)
get Resource to serve.
void
handleDelete(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource)
void
handleGet(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource, boolean endsWithSlash)
void
handleMove(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource)
void
handleOptions(HttpServletRequest request, HttpServletResponse response)
void
handlePut(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource)
void
init()
A convenience method which can be overridden so that there's no need to call super.init(config).
protected boolean
passConditionalHeaders(HttpServletRequest request, HttpServletResponse response, Resource resource)
protected void
sendData(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource)
protected void
sendDirectory(HttpServletRequest request, HttpServletResponse response, Resource resource, boolean parent)
protected void
service(HttpServletRequest request, HttpServletResponse response)
protected void
writeHeaders(HttpServletResponse response, Resource resource, long count)

Methods inherited from class javax.servlet.http.HttpServlet

doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service

Methods inherited from class javax.servlet.GenericServlet

destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log, service

Method Details

getResource

protected Resource getResource(String pathInContext)
            throws IOException
get Resource to serve. Map a path to a resource. The default implementation calls HttpContext.getResource but derived servlets may provide their own mapping.
Parameters:
pathInContext - The path to find a resource for.
Returns:
The resource to serve.

handleDelete

public void handleDelete(HttpServletRequest request,
                         HttpServletResponse response,
                         String pathInContext,
                         Resource resource)
            throws ServletException,
                   IOException

handleGet

public void handleGet(HttpServletRequest request,
                      HttpServletResponse response,
                      String pathInContext,
                      Resource resource,
                      boolean endsWithSlash)
            throws ServletException,
                   IOException

handleMove

public void handleMove(HttpServletRequest request,
                       HttpServletResponse response,
                       String pathInContext,
                       Resource resource)
            throws ServletException,
                   IOException

handleOptions

public void handleOptions(HttpServletRequest request,
                          HttpServletResponse response)
            throws IOException

handlePut

public void handlePut(HttpServletRequest request,
                      HttpServletResponse response,
                      String pathInContext,
                      Resource resource)
            throws ServletException,
                   IOException

init

public void init()
            throws UnavailableException
A convenience method which can be overridden so that there's no need to call super.init(config).

Instead of overriding GenericServlet.init(ServletConfig), simply override this method and it will be called by GenericServlet.init(ServletConfig config). The ServletConfig object can still be retrieved via GenericServlet.getServletConfig().

Overrides:
init in interface GenericServlet

passConditionalHeaders

protected boolean passConditionalHeaders(HttpServletRequest request,
                                         HttpServletResponse response,
                                         Resource resource)
            throws IOException

sendData

protected void sendData(HttpServletRequest request,
                        HttpServletResponse response,
                        String pathInContext,
                        Resource resource)
            throws IOException

sendDirectory

protected void sendDirectory(HttpServletRequest request,
                             HttpServletResponse response,
                             Resource resource,
                             boolean parent)
            throws IOException

service

protected void service(HttpServletRequest request,
                       HttpServletResponse response)
            throws ServletException,
                   IOException
Overrides:
service in interface HttpServlet

writeHeaders

protected void writeHeaders(HttpServletResponse response,
                            Resource resource,
                            long count)
            throws IOException

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.