org.mortbay.jetty.servlet
Class Default
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.mortbay.jetty.servlet.Default
- All 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.51 2006/10/08 14:13:18 gregwilkins Exp $
- Author:
- Greg Wilkins (gregw)
- See Also:
- Serialized Form
Method Summary |
protected Resource |
getResource(java.lang.String pathInContext)
get Resource to serve. |
void |
handleDelete(HttpServletRequest request,
HttpServletResponse response,
java.lang.String pathInContext,
Resource resource)
|
void |
handleGet(HttpServletRequest request,
HttpServletResponse response,
java.lang.String pathInContext,
Resource resource,
boolean endsWithSlash)
|
void |
handleMove(HttpServletRequest request,
HttpServletResponse response,
java.lang.String pathInContext,
Resource resource)
|
void |
handleOptions(HttpServletRequest request,
HttpServletResponse response)
|
void |
handlePut(HttpServletRequest request,
HttpServletResponse response,
java.lang.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,
java.lang.String pathInContext,
Resource resource)
|
protected void |
sendDirectory(HttpServletRequest request,
HttpServletResponse response,
Resource resource,
boolean parent)
|
protected void |
service(HttpServletRequest request,
HttpServletResponse response)
Receives standard HTTP requests from the public
service method and dispatches
them to the do XXX methods defined in
this class. |
protected void |
writeHeaders(HttpServletResponse response,
Resource resource,
long count)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Default
public Default()
init
public void init()
throws UnavailableException
- Description copied from class:
GenericServlet
- 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 class GenericServlet
- Throws:
UnavailableException
getResource
protected Resource getResource(java.lang.String pathInContext)
throws java.io.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.
- Throws:
java.io.IOException
service
protected void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
java.io.IOException
- Description copied from class:
HttpServlet
- Receives standard HTTP requests from the public
service
method and dispatches
them to the do
XXX methods defined in
this class. This method is an HTTP-specific version of the
Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
method. There's no
need to override this method.
- Overrides:
service
in class HttpServlet
- Parameters:
request
- the HttpServletRequest
object that
contains the request the client made of the servletresponse
- the HttpServletResponse
object that
contains the response the servlet returns to the client
- Throws:
ServletException
- if the HTTP request
cannot be handled
java.io.IOException
- if an input or output error occurs
while the servlet is handling the HTTP request- See Also:
Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
handleGet
public void handleGet(HttpServletRequest request,
HttpServletResponse response,
java.lang.String pathInContext,
Resource resource,
boolean endsWithSlash)
throws ServletException,
java.io.IOException
- Throws:
ServletException
java.io.IOException
handlePut
public void handlePut(HttpServletRequest request,
HttpServletResponse response,
java.lang.String pathInContext,
Resource resource)
throws ServletException,
java.io.IOException
- Throws:
ServletException
java.io.IOException
handleDelete
public void handleDelete(HttpServletRequest request,
HttpServletResponse response,
java.lang.String pathInContext,
Resource resource)
throws ServletException,
java.io.IOException
- Throws:
ServletException
java.io.IOException
handleMove
public void handleMove(HttpServletRequest request,
HttpServletResponse response,
java.lang.String pathInContext,
Resource resource)
throws ServletException,
java.io.IOException
- Throws:
ServletException
java.io.IOException
handleOptions
public void handleOptions(HttpServletRequest request,
HttpServletResponse response)
throws java.io.IOException
- Throws:
java.io.IOException
passConditionalHeaders
protected boolean passConditionalHeaders(HttpServletRequest request,
HttpServletResponse response,
Resource resource)
throws java.io.IOException
- Throws:
java.io.IOException
sendDirectory
protected void sendDirectory(HttpServletRequest request,
HttpServletResponse response,
Resource resource,
boolean parent)
throws java.io.IOException
- Throws:
java.io.IOException
sendData
protected void sendData(HttpServletRequest request,
HttpServletResponse response,
java.lang.String pathInContext,
Resource resource)
throws java.io.IOException
- Throws:
java.io.IOException
writeHeaders
protected void writeHeaders(HttpServletResponse response,
Resource resource,
long count)
throws java.io.IOException
- Throws:
java.io.IOException
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.