org.mortbay.jetty.servlet
Class DefaultServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.mortbay.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:
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.
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.
maxByteBuffer The maximum size of byte buffer content
maxDirectBuffer The maximum size of NIO direct buffer content
maxFileBuffer The maximum size of NIO file mapped buffer content
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
The MOVE method is allowed if PUT and DELETE are allowed
- Author:
- Greg Wilkins (gregw)
- See Also:
- Serialized Form
Method Summary |
void |
destroy()
|
protected void |
doGet(HttpServletRequest request,
HttpServletResponse response)
|
private DefaultServlet.Content |
getContent(String pathInContext,
Resource resource)
|
private boolean |
getInitBoolean(String name,
boolean dft)
|
private int |
getInitInt(String name,
int dft)
|
Resource |
getResource(String pathInContext)
get Resource to serve. |
private String |
getWelcomeFile(Resource resource)
|
void |
init()
|
protected boolean |
passConditionalHeaders(HttpServletRequest request,
HttpServletResponse response,
Resource resource,
DefaultServlet.Content content)
|
protected void |
sendData(HttpServletRequest request,
HttpServletResponse response,
boolean include,
Resource resource,
DefaultServlet.Content content,
Enumeration reqRanges)
|
protected void |
sendDirectory(HttpServletRequest request,
HttpServletResponse response,
Resource resource,
boolean parent)
|
protected void |
writeHeaders(HttpServletResponse response,
DefaultServlet.Content content,
long count)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_context
private ContextHandler.Context _context
_maxByteBuffer
private int _maxByteBuffer
_maxDirectBuffer
private int _maxDirectBuffer
_maxFileBuffer
private int _maxFileBuffer
_acceptRanges
private boolean _acceptRanges
_dirAllowed
private boolean _dirAllowed
_redirectWelcome
private boolean _redirectWelcome
_gzip
private boolean _gzip
_resourceBase
private Resource _resourceBase
_cache
private ResourceCache _cache
_mimeTypes
private MimeTypes _mimeTypes
_welcomes
private String[] _welcomes
DefaultServlet
public DefaultServlet()
init
public void init()
throws UnavailableException
- Overrides:
init
in class GenericServlet
- Throws:
UnavailableException
getInitBoolean
private boolean getInitBoolean(String name,
boolean dft)
getInitInt
private int getInitInt(String name,
int dft)
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
getContent
private DefaultServlet.Content getContent(String pathInContext,
Resource resource)
throws IOException
- Throws:
IOException
getWelcomeFile
private String getWelcomeFile(Resource resource)
throws MalformedURLException,
IOException
- Parameters:
resource
-
- Returns:
-
- Throws:
IOException
MalformedURLException
passConditionalHeaders
protected boolean passConditionalHeaders(HttpServletRequest request,
HttpServletResponse response,
Resource resource,
DefaultServlet.Content content)
throws IOException
- Throws:
IOException
sendDirectory
protected void sendDirectory(HttpServletRequest request,
HttpServletResponse response,
Resource resource,
boolean parent)
throws IOException
- Throws:
IOException
sendData
protected void sendData(HttpServletRequest request,
HttpServletResponse response,
boolean include,
Resource resource,
DefaultServlet.Content content,
Enumeration reqRanges)
throws IOException
- Throws:
IOException
writeHeaders
protected void writeHeaders(HttpServletResponse response,
DefaultServlet.Content content,
long count)
throws IOException
- Throws:
IOException
destroy
public void destroy()
- Specified by:
destroy
in interface Servlet
- Overrides:
destroy
in class GenericServlet