org.eclipse.jetty.util.resource.ResourceFactorypublic class DefaultServlet
extends javax.servlet.http.HttpServlet
implements org.eclipse.jetty.util.resource.ResourceFactory
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.
etags If True, weak etags will be generated and handled.
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.
This is set to false by default by this class, but may be overridden
by eg webdefault.xml
cacheControl If set, all static content will have this value set as the cache-control
header.
otherGzipFileExtensions
Other file extensions that signify that a file is gzip compressed. Eg ".svgz"
| Constructor | Description |
|---|---|
DefaultServlet() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
destroy() |
|
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
|
protected void |
doOptions(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) |
|
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) |
|
org.eclipse.jetty.util.resource.Resource |
getResource(java.lang.String pathInContext) |
get Resource to serve.
|
void |
init() |
|
protected org.eclipse.jetty.server.handler.ContextHandler |
initContextHandler(javax.servlet.ServletContext servletContext) |
Compute the field _contextHandler.
In the case where the DefaultServlet is deployed on the HttpService it is likely that this method needs to be overwritten to unwrap the ServletContext facade until we reach the original jetty's ContextHandler. |
protected boolean |
isGzippedContent(java.lang.String path) |
|
protected boolean |
passConditionalHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.eclipse.jetty.http.HttpContent content) |
|
protected void |
putHeaders(javax.servlet.http.HttpServletResponse response,
org.eclipse.jetty.http.HttpContent content,
long contentLength) |
|
protected boolean |
sendData(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean include,
org.eclipse.jetty.http.HttpContent content,
java.util.Enumeration<java.lang.String> reqRanges) |
|
protected void |
sendDirectory(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.eclipse.jetty.util.resource.Resource resource,
java.lang.String pathInContext) |
|
protected void |
sendWelcome(org.eclipse.jetty.http.HttpContent content,
java.lang.String pathInContext,
boolean endsWithSlash,
boolean included,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, logpublic void init()
throws javax.servlet.UnavailableException
init in class javax.servlet.GenericServletjavax.servlet.UnavailableExceptionprotected org.eclipse.jetty.server.handler.ContextHandler initContextHandler(javax.servlet.ServletContext servletContext)
servletContext - The servletContext of this servlet.public java.lang.String getInitParameter(java.lang.String name)
getInitParameter in class javax.servlet.GenericServletpublic org.eclipse.jetty.util.resource.Resource getResource(java.lang.String pathInContext)
getResource in interface org.eclipse.jetty.util.resource.ResourceFactorypathInContext - The path to find a resource for.protected void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
doGet in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionjava.io.IOExceptionprotected void sendWelcome(org.eclipse.jetty.http.HttpContent content,
java.lang.String pathInContext,
boolean endsWithSlash,
boolean included,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
javax.servlet.ServletExceptionjava.io.IOExceptionprotected boolean isGzippedContent(java.lang.String path)
protected void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
doPost in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionjava.io.IOExceptionprotected void doTrace(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
doTrace in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionjava.io.IOExceptionprotected void doOptions(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
doOptions in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionjava.io.IOExceptionprotected boolean passConditionalHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.eclipse.jetty.http.HttpContent content)
throws java.io.IOException
java.io.IOExceptionprotected void sendDirectory(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.eclipse.jetty.util.resource.Resource resource,
java.lang.String pathInContext)
throws java.io.IOException
java.io.IOExceptionprotected boolean sendData(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean include,
org.eclipse.jetty.http.HttpContent content,
java.util.Enumeration<java.lang.String> reqRanges)
throws java.io.IOException
java.io.IOExceptionprotected void putHeaders(javax.servlet.http.HttpServletResponse response,
org.eclipse.jetty.http.HttpContent content,
long contentLength)
public void destroy()
destroy in class javax.servlet.GenericServletCopyright © 1995–2018 Webtide. All rights reserved.