|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.GenericServlet javax.servlet.http.HttpServlet org.apache.catalina.servlets.DefaultServlet
public class DefaultServlet
The default resource-serving servlet for most web applications, used to serve static resources such as HTML pages and images.
This servlet is intended to be mapped to / e.g.:
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
It can be mapped to sub-paths, however in all cases resources are served
from the web appplication resource root using the full path from the root
of the web application context.
e.g. given a web application structure:
/context /images tomcat2.jpg /static /images tomcat.jpg
... and a servlet mapping that maps only /static/*
to the default servlet:
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/static/*</url-pattern> </servlet-mapping>
Then a request to /context/static/images/tomcat.jpg
will succeed
while a request to /context/images/tomcat2.jpg
will fail.
Nested Class Summary | |
---|---|
protected class |
DefaultServlet.Range
|
Field Summary | |
---|---|
protected static int |
BUFFER_SIZE
Size of file transfer buffer in bytes. |
protected java.lang.String |
contextXsltFile
Allow customized directory listing per context. |
protected int |
debug
The debugging detail level for this servlet. |
protected java.lang.String |
fileEncoding
File encoding to be used when reading static files. |
protected static java.util.ArrayList |
FULL
Full range marker. |
protected java.lang.String |
globalXsltFile
Allow customized directory listing per instance. |
protected int |
input
The input buffer size to use when serving resources. |
protected boolean |
listings
Should we generate directory listings? |
protected java.lang.String |
localXsltFile
Allow customized directory listing per directory. |
protected static java.lang.String |
mimeSeparation
MIME multipart separation string |
protected int |
output
The output buffer size to use when serving resources. |
protected java.lang.String |
readmeFile
Allow a readme file to be included. |
protected boolean |
readOnly
Read only flag. |
protected ProxyDirContext |
resources
Proxy directory context. |
protected static java.lang.String |
RESOURCES_JNDI_NAME
JNDI resources name. |
protected int |
sendfileSize
Minimum size for sendfile usage in bytes. |
protected static StringManager |
sm
The string manager for this package. |
protected static URLEncoder |
urlEncoder
Array containing the safe characters set. |
protected boolean |
useAcceptRanges
Should the Accept-Ranges: bytes header be send with static resources? |
Constructor Summary | |
---|---|
DefaultServlet()
|
Method Summary | |
---|---|
protected boolean |
checkIfHeaders(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ResourceAttributes resourceAttributes)
Check if the conditions specified in the optional If headers are satisfied. |
protected boolean |
checkIfMatch(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ResourceAttributes resourceAttributes)
Check if the if-match condition is satisfied. |
protected boolean |
checkIfModifiedSince(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ResourceAttributes resourceAttributes)
Check if the if-modified-since condition is satisfied. |
protected boolean |
checkIfNoneMatch(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ResourceAttributes resourceAttributes)
Check if the if-none-match condition is satisfied. |
protected boolean |
checkIfUnmodifiedSince(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ResourceAttributes resourceAttributes)
Check if the if-unmodified-since condition is satisfied. |
protected boolean |
checkSendfile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
CacheEntry entry,
long length,
DefaultServlet.Range range)
Check if sendfile can be used. |
protected void |
copy(CacheEntry cacheEntry,
java.io.InputStream is,
java.io.PrintWriter writer)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected void |
copy(CacheEntry cacheEntry,
java.io.InputStream is,
javax.servlet.ServletOutputStream ostream)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected void |
copy(CacheEntry cacheEntry,
java.io.PrintWriter writer,
DefaultServlet.Range range)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected void |
copy(CacheEntry cacheEntry,
java.io.PrintWriter writer,
java.util.Iterator ranges,
java.lang.String contentType)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected void |
copy(CacheEntry cacheEntry,
javax.servlet.ServletOutputStream ostream,
DefaultServlet.Range range)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected void |
copy(CacheEntry cacheEntry,
javax.servlet.ServletOutputStream ostream,
java.util.Iterator ranges,
java.lang.String contentType)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected java.io.IOException |
copyRange(java.io.InputStream istream,
javax.servlet.ServletOutputStream ostream)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected java.io.IOException |
copyRange(java.io.InputStream istream,
javax.servlet.ServletOutputStream ostream,
long start,
long end)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected java.io.IOException |
copyRange(java.io.Reader reader,
java.io.PrintWriter writer)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
protected java.io.IOException |
copyRange(java.io.Reader reader,
java.io.PrintWriter writer,
long start,
long end)
Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception). |
void |
destroy()
Finalize this servlet. |
protected void |
displaySize(java.lang.StringBuffer buf,
int filesize)
Display the size of a file. |
protected void |
doDelete(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Process a POST request for the specified resource. |
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Process a GET request for the specified resource. |
protected void |
doHead(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Process a HEAD request for the specified resource. |
protected void |
doOptions(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Override default implementation to ensure that TRACE is correctly handled. |
protected void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Process a POST request for the specified resource. |
protected void |
doPut(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Process a POST request for the specified resource. |
protected java.io.File |
executePartialPut(javax.servlet.http.HttpServletRequest req,
DefaultServlet.Range range,
java.lang.String path)
Handle a partial PUT. |
protected javax.xml.transform.Source |
findXsltInputStream(javax.naming.directory.DirContext directory)
Return a Source for the xsl template (if possible) |
protected java.lang.String |
getPathPrefix(javax.servlet.http.HttpServletRequest request)
Determines the appropriate path to prepend resources with when generating directory listings. |
protected java.lang.String |
getReadme(javax.naming.directory.DirContext directory)
Get the readme file as a string. |
protected java.lang.String |
getRelativePath(javax.servlet.http.HttpServletRequest request)
Return the relative path associated with this servlet. |
protected java.lang.String |
getRelativePath(javax.servlet.http.HttpServletRequest request,
boolean allowEmptyPath)
|
void |
init()
Initialize this servlet. |
protected DefaultServlet.Range |
parseContentRange(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Parse the content-range header. |
protected java.util.ArrayList |
parseRange(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ResourceAttributes resourceAttributes)
Parse the range header. |
protected java.io.InputStream |
render(java.lang.String contextPath,
CacheEntry cacheEntry)
Decide which way to render. |
protected java.io.InputStream |
renderHtml(java.lang.String contextPath,
CacheEntry cacheEntry)
Return an InputStream to an HTML representation of the contents of this directory. |
protected java.lang.String |
renderSize(long size)
Render the specified file size (in bytes). |
protected java.io.InputStream |
renderXml(java.lang.String contextPath,
CacheEntry cacheEntry,
javax.xml.transform.Source xsltSource)
Return an InputStream to an HTML representation of the contents of this directory. |
protected java.lang.String |
rewriteUrl(java.lang.String path)
URL rewriter. |
protected void |
serveResource(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
boolean content)
Serve the specified resource, optionally including the data content. |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
getInitParameter, 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 |
Field Detail |
---|
protected int debug
protected int input
protected boolean listings
protected boolean readOnly
protected int output
protected static URLEncoder urlEncoder
protected java.lang.String localXsltFile
protected java.lang.String contextXsltFile
protected java.lang.String globalXsltFile
protected java.lang.String readmeFile
protected ProxyDirContext resources
protected java.lang.String fileEncoding
protected int sendfileSize
protected boolean useAcceptRanges
protected static java.util.ArrayList FULL
protected static final java.lang.String mimeSeparation
protected static final java.lang.String RESOURCES_JNDI_NAME
protected static StringManager sm
protected static final int BUFFER_SIZE
Constructor Detail |
---|
public DefaultServlet()
Method Detail |
---|
public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
public void init() throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
- if an exception occurs that
interrupts the servlet's
normal operationprotected java.lang.String getRelativePath(javax.servlet.http.HttpServletRequest request)
request
- The servlet request we are processingprotected java.lang.String getRelativePath(javax.servlet.http.HttpServletRequest request, boolean allowEmptyPath)
protected java.lang.String getPathPrefix(javax.servlet.http.HttpServletRequest request)
getRelativePath(HttpServletRequest)
this will change.
request
- the request to determine the path for
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doGet
in class javax.servlet.http.HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creating
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet-specified error occursServletResponse.setContentType(java.lang.String)
protected void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doHead
in class javax.servlet.http.HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creating
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet-specified error occursprotected 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.HttpServlet
req
- the HttpServletRequest
object that
contains the request the client made of
the servletresp
- the HttpServletResponse
object that
contains the response the servlet returns
to the client
java.io.IOException
- if an input or output error occurs
while the servlet is handling the
OPTIONS request
javax.servlet.ServletException
- if the request for the
OPTIONS cannot be handledprotected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
doPost
in class javax.servlet.http.HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creating
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet-specified error occursServletOutputStream
,
ServletResponse.setContentType(java.lang.String)
protected void doPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException
doPut
in class javax.servlet.http.HttpServlet
req
- The servlet request we are processingresp
- The servlet response we are creating
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet-specified error occursprotected java.io.File executePartialPut(javax.servlet.http.HttpServletRequest req, DefaultServlet.Range range, java.lang.String path) throws java.io.IOException
java.io.IOException
protected void doDelete(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOException
doDelete
in class javax.servlet.http.HttpServlet
req
- The servlet request we are processingresp
- The servlet response we are creating
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet-specified error occursprotected boolean checkIfHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws java.io.IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceAttributes
- The resource information
java.io.IOException
protected java.lang.String rewriteUrl(java.lang.String path)
path
- Path which has to be rewitenprotected void displaySize(java.lang.StringBuffer buf, int filesize)
protected void serveResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean content) throws java.io.IOException, javax.servlet.ServletException
request
- The servlet request we are processingresponse
- The servlet response we are creatingcontent
- Should the content be included?
java.io.IOException
- if an input/output error occurs
javax.servlet.ServletException
- if a servlet-specified error occursprotected DefaultServlet.Range parseContentRange(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
request
- The servlet request we are processingresponse
- The servlet response we are creating
java.io.IOException
protected java.util.ArrayList parseRange(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws java.io.IOException
request
- The servlet request we are processingresponse
- The servlet response we are creating
java.io.IOException
protected java.io.InputStream render(java.lang.String contextPath, CacheEntry cacheEntry) throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
protected java.io.InputStream renderXml(java.lang.String contextPath, CacheEntry cacheEntry, javax.xml.transform.Source xsltSource) throws java.io.IOException, javax.servlet.ServletException
contextPath
- Context path to which our internal paths are
relative
java.io.IOException
javax.servlet.ServletException
protected java.io.InputStream renderHtml(java.lang.String contextPath, CacheEntry cacheEntry) throws java.io.IOException, javax.servlet.ServletException
contextPath
- Context path to which our internal paths are
relative
java.io.IOException
javax.servlet.ServletException
protected java.lang.String renderSize(long size)
size
- File size (in bytes)protected java.lang.String getReadme(javax.naming.directory.DirContext directory) throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
protected javax.xml.transform.Source findXsltInputStream(javax.naming.directory.DirContext directory) throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
protected boolean checkSendfile(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, CacheEntry entry, long length, DefaultServlet.Range range)
protected boolean checkIfMatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws java.io.IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceAttributes
- Attributes of requested resource
java.io.IOException
protected boolean checkIfModifiedSince(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws java.io.IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceAttributes
- Attributes of requested resource
java.io.IOException
protected boolean checkIfNoneMatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws java.io.IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceAttributes
- Attributes of requested resource
java.io.IOException
protected boolean checkIfUnmodifiedSince(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws java.io.IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceAttributes
- Attributes of requested resource
java.io.IOException
protected void copy(CacheEntry cacheEntry, java.io.InputStream is, javax.servlet.ServletOutputStream ostream) throws java.io.IOException
cacheEntry
- Cached version of requested resourceostream
- The output stream to write to
java.io.IOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, java.io.InputStream is, java.io.PrintWriter writer) throws java.io.IOException
cacheEntry
- Cached version of requested resourcewriter
- The writer to write to
java.io.IOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, javax.servlet.ServletOutputStream ostream, DefaultServlet.Range range) throws java.io.IOException
cacheEntry
- Cached version of requested resourceostream
- The output stream to write torange
- Range the client wanted to retrieve
java.io.IOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, java.io.PrintWriter writer, DefaultServlet.Range range) throws java.io.IOException
cacheEntry
- Cached version of requested resourcewriter
- The writer to write torange
- Range the client wanted to retrieve
java.io.IOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, javax.servlet.ServletOutputStream ostream, java.util.Iterator ranges, java.lang.String contentType) throws java.io.IOException
cacheEntry
- Cached version of requested resourceostream
- The output stream to write toranges
- Enumeration of the ranges the client wanted to retrievecontentType
- Content type of the resource
java.io.IOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, java.io.PrintWriter writer, java.util.Iterator ranges, java.lang.String contentType) throws java.io.IOException
cacheEntry
- Cached version of requested resourcewriter
- The writer to write toranges
- Enumeration of the ranges the client wanted to retrievecontentType
- Content type of the resource
java.io.IOException
- if an input/output error occursprotected java.io.IOException copyRange(java.io.InputStream istream, javax.servlet.ServletOutputStream ostream)
istream
- The input stream to read fromostream
- The output stream to write to
protected java.io.IOException copyRange(java.io.Reader reader, java.io.PrintWriter writer)
reader
- The reader to read fromwriter
- The writer to write to
protected java.io.IOException copyRange(java.io.InputStream istream, javax.servlet.ServletOutputStream ostream, long start, long end)
istream
- The input stream to read fromostream
- The output stream to write tostart
- Start of the range which will be copiedend
- End of the range which will be copied
protected java.io.IOException copyRange(java.io.Reader reader, java.io.PrintWriter writer, long start, long end)
reader
- The reader to read fromwriter
- The writer to write tostart
- Start of the range which will be copiedend
- End of the range which will be copied
|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |