Package org.apache.catalina.servlets
Class DefaultServlet
- java.lang.Object
- 
- javax.servlet.GenericServlet
- 
- javax.servlet.http.HttpServlet
- 
- org.apache.catalina.servlets.DefaultServlet
 
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- Servlet,- ServletConfig
 - Direct Known Subclasses:
- WebdavServlet
 
 public class DefaultServlet extends HttpServlet 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 application 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.jpgwill succeed while a request to/context/images/tomcat2.jpgwill fail.- Author:
- Craig R. McClanahan, Remy Maucherat
- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classDefaultServlet.CompressionFormatprotected static classDefaultServlet.Range
 - 
Field SummaryFields Modifier and Type Field Description protected static intBUFFER_SIZESize of file transfer buffer in bytes.protected DefaultServlet.CompressionFormat[]compressionFormatsList of compression formats to serve and their preference order.protected java.lang.StringcontextXsltFileAllow customized directory listing per context.protected intdebugThe debugging detail level for this servlet.protected java.lang.StringfileEncodingFile encoding to be used when reading static files.protected static java.util.ArrayList<DefaultServlet.Range>FULLFull range marker.protected java.lang.StringglobalXsltFileAllow customized directory listing per instance.protected intinputThe input buffer size to use when serving resources.protected booleanlistingsShould we generate directory listings?protected java.lang.StringlocalXsltFileAllow customized directory listing per directory.protected static java.lang.StringmimeSeparationMIME multipart separation stringprotected intoutputThe output buffer size to use when serving resources.protected java.lang.StringreadmeFileAllow a readme file to be included.protected booleanreadOnlyRead only flag.protected WebResourceRootresourcesThe complete set of web application resourcesprotected static java.lang.StringRESOURCES_JNDI_NAMEDeprecated.Unused.protected intsendfileSizeMinimum size for sendfile usage in bytes.protected booleanshowServerInfoFlag to determine if server information is presented.protected static StringManagersmThe string manager for this package.protected booleansortListingsFlag to determine if resources should be sorted.protected org.apache.catalina.servlets.DefaultServlet.SortManagersortManagerThe sorting manager for sorting files and directories.protected booleanuseAcceptRangesShould the Accept-Ranges: bytes header be send with static resources?
 - 
Constructor SummaryConstructors Constructor Description DefaultServlet()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected booleancheckIfHeaders(HttpServletRequest request, HttpServletResponse response, WebResource resource)Check if the conditions specified in the optional If headers are satisfied.protected booleancheckIfMatch(HttpServletRequest request, HttpServletResponse response, WebResource resource)Check if the if-match condition is satisfied.protected booleancheckIfModifiedSince(HttpServletRequest request, HttpServletResponse response, WebResource resource)Check if the if-modified-since condition is satisfied.protected booleancheckIfNoneMatch(HttpServletRequest request, HttpServletResponse response, WebResource resource)Check if the if-none-match condition is satisfied.protected booleancheckIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, WebResource resource)Check if the if-unmodified-since condition is satisfied.protected booleancheckSendfile(HttpServletRequest request, HttpServletResponse response, WebResource resource, long length, DefaultServlet.Range range)Check if sendfile can be used.protected voidcopy(java.io.InputStream is, java.io.PrintWriter writer, java.lang.String encoding)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 voidcopy(java.io.InputStream is, 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 voidcopy(WebResource resource, java.io.InputStream is, java.io.PrintWriter writer, java.lang.String encoding)Deprecated.Unused.protected voidcopy(WebResource resource, java.io.InputStream is, ServletOutputStream ostream)Deprecated.Unused.protected voidcopy(WebResource resource, ServletOutputStream ostream, java.util.Iterator<DefaultServlet.Range> 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 voidcopy(WebResource resource, 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 java.io.IOExceptioncopyRange(java.io.InputStream istream, 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.IOExceptioncopyRange(java.io.InputStream istream, 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.IOExceptioncopyRange(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).voiddestroy()Finalize this servlet.protected java.lang.StringdetermineMethodsAllowed(HttpServletRequest req)protected voiddoDelete(HttpServletRequest req, HttpServletResponse resp)Process a DELETE request for the specified resource.protected voiddoGet(HttpServletRequest request, HttpServletResponse response)Process a GET request for the specified resource.protected voiddoHead(HttpServletRequest request, HttpServletResponse response)Process a HEAD request for the specified resource.protected voiddoOptions(HttpServletRequest req, HttpServletResponse resp)Override default implementation to ensure that TRACE is correctly handled.protected voiddoPost(HttpServletRequest request, HttpServletResponse response)Process a POST request for the specified resource.protected voiddoPut(HttpServletRequest req, HttpServletResponse resp)Process a PUT request for the specified resource.protected java.io.FileexecutePartialPut(HttpServletRequest req, DefaultServlet.Range range, java.lang.String path)Handle a partial PUT.protected javax.xml.transform.SourcefindXsltSource(WebResource directory)Return a Source for the xsl template (if possible).protected java.lang.StringgenerateETag(WebResource resource)Provides the entity tag (the ETag header) for the given resource.protected java.lang.StringgetPathPrefix(HttpServletRequest request)Determines the appropriate path to prepend resources with when generating directory listings.protected java.lang.StringgetReadme(WebResource directory)Deprecated.Unused.protected java.lang.StringgetReadme(WebResource directory, java.lang.String encoding)Get the readme file as a string.protected java.lang.StringgetRelativePath(HttpServletRequest request)Return the relative path associated with this servlet.protected java.lang.StringgetRelativePath(HttpServletRequest request, boolean allowEmptyPath)voidinit()Initialize this servlet.protected DefaultServlet.RangeparseContentRange(HttpServletRequest request, HttpServletResponse response)Parse the content-range header.protected java.util.ArrayList<DefaultServlet.Range>parseRange(HttpServletRequest request, HttpServletResponse response, WebResource resource)Parse the range header.protected java.io.InputStreamrender(java.lang.String contextPath, WebResource resource)Deprecated.Unused.protected java.io.InputStreamrender(java.lang.String contextPath, WebResource resource, java.lang.String encoding)Deprecated.protected java.io.InputStreamrender(HttpServletRequest request, java.lang.String contextPath, WebResource resource, java.lang.String encoding)Decide which way to render.protected java.io.InputStreamrenderHtml(java.lang.String contextPath, WebResource resource)Deprecated.Unused.protected java.io.InputStreamrenderHtml(java.lang.String contextPath, WebResource resource, java.lang.String encoding)Deprecated.Unused.protected java.io.InputStreamrenderHtml(HttpServletRequest request, java.lang.String contextPath, WebResource resource, java.lang.String encoding)Return an InputStream to an HTML representation of the contents of this directory.protected java.lang.StringrenderSize(long size)Render the specified file size (in bytes).protected java.io.InputStreamrenderXml(java.lang.String contextPath, WebResource resource, javax.xml.transform.Source xsltSource)Deprecated.Unused.protected java.io.InputStreamrenderXml(java.lang.String contextPath, WebResource resource, javax.xml.transform.Source xsltSource, java.lang.String encoding)Deprecated.Unused.protected java.io.InputStreamrenderXml(HttpServletRequest request, java.lang.String contextPath, WebResource resource, javax.xml.transform.Source xsltSource, java.lang.String encoding)Return an InputStream to an XML representation of the contents this directory.protected java.lang.StringrewriteUrl(java.lang.String path)URL rewriter.protected voidsendNotAllowed(HttpServletRequest req, HttpServletResponse resp)protected voidserveResource(HttpServletRequest request, HttpServletResponse response, boolean content, java.lang.String inputEncoding)Serve the specified resource, optionally including the data content.protected voidservice(HttpServletRequest req, HttpServletResponse resp)Receives standard HTTP requests from the publicservicemethod and dispatches them to thedoMethod methods defined in this class.- 
Methods inherited from class javax.servlet.http.HttpServletdoTrace, getLastModified, service
 - 
Methods inherited from class javax.servlet.GenericServletgetInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
- 
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm The string manager for this package.
 - 
FULLprotected static final java.util.ArrayList<DefaultServlet.Range> FULL Full range marker.
 - 
mimeSeparationprotected static final java.lang.String mimeSeparation MIME multipart separation string- See Also:
- Constant Field Values
 
 - 
RESOURCES_JNDI_NAME@Deprecated protected static final java.lang.String RESOURCES_JNDI_NAME Deprecated.Unused. Will be removed in Tomcat 9.JNDI resources name.- See Also:
- Constant Field Values
 
 - 
BUFFER_SIZEprotected static final int BUFFER_SIZE Size of file transfer buffer in bytes.- See Also:
- Constant Field Values
 
 - 
debugprotected int debug The debugging detail level for this servlet.
 - 
inputprotected int input The input buffer size to use when serving resources.
 - 
listingsprotected boolean listings Should we generate directory listings?
 - 
readOnlyprotected boolean readOnly Read only flag. By default, it's set to true.
 - 
compressionFormatsprotected DefaultServlet.CompressionFormat[] compressionFormats List of compression formats to serve and their preference order.
 - 
outputprotected int output The output buffer size to use when serving resources.
 - 
localXsltFileprotected java.lang.String localXsltFile Allow customized directory listing per directory.
 - 
contextXsltFileprotected java.lang.String contextXsltFile Allow customized directory listing per context.
 - 
globalXsltFileprotected java.lang.String globalXsltFile Allow customized directory listing per instance.
 - 
readmeFileprotected java.lang.String readmeFile Allow a readme file to be included.
 - 
resourcesprotected transient WebResourceRoot resources The complete set of web application resources
 - 
fileEncodingprotected java.lang.String fileEncoding File encoding to be used when reading static files. If none is specified the platform default is used.
 - 
sendfileSizeprotected int sendfileSize Minimum size for sendfile usage in bytes.
 - 
useAcceptRangesprotected boolean useAcceptRanges Should the Accept-Ranges: bytes header be send with static resources?
 - 
showServerInfoprotected boolean showServerInfo Flag to determine if server information is presented.
 - 
sortListingsprotected boolean sortListings Flag to determine if resources should be sorted.
 - 
sortManagerprotected transient org.apache.catalina.servlets.DefaultServlet.SortManager sortManager The sorting manager for sorting files and directories.
 
- 
 - 
Method Detail- 
destroypublic void destroy() Finalize this servlet.- Specified by:
- destroyin interface- Servlet
- Overrides:
- destroyin class- GenericServlet
 
 - 
initpublic void init() throws ServletExceptionInitialize this servlet.- Overrides:
- initin class- GenericServlet
- Throws:
- ServletException- if an exception occurs that interrupts the servlet's normal operation
 
 - 
getRelativePathprotected java.lang.String getRelativePath(HttpServletRequest request) Return the relative path associated with this servlet.- Parameters:
- request- The servlet request we are processing
- Returns:
- the relative path
 
 - 
getRelativePathprotected java.lang.String getRelativePath(HttpServletRequest request, boolean allowEmptyPath) 
 - 
getPathPrefixprotected java.lang.String getPathPrefix(HttpServletRequest request) Determines the appropriate path to prepend resources with when generating directory listings. Depending on the behaviour ofgetRelativePath(HttpServletRequest)this will change.- Parameters:
- request- the request to determine the path for
- Returns:
- the prefix to apply to all resources in the listing.
 
 - 
serviceprotected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException Description copied from class:javax.servlet.http.HttpServletReceives standard HTTP requests from the publicservicemethod and dispatches them to thedoMethod methods defined in this class. This method is an HTTP-specific version of theServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)method. There's no need to override this method.- Overrides:
- servicein class- HttpServlet
- Parameters:
- req- the- HttpServletRequestobject that contains the request the client made of the servlet
- resp- the- HttpServletResponseobject 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)
 
 - 
doGetprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException Process a GET request for the specified resource.- Overrides:
- doGetin class- HttpServlet
- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet-specified error occurs
- See Also:
- ServletResponse.setContentType(java.lang.String)
 
 - 
doHeadprotected void doHead(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException Process a HEAD request for the specified resource.- Overrides:
- doHeadin class- HttpServlet
- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet-specified error occurs
 
 - 
doOptionsprotected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException Override default implementation to ensure that TRACE is correctly handled.- Overrides:
- doOptionsin class- HttpServlet
- Parameters:
- req- the- HttpServletRequestobject that contains the request the client made of the servlet
- resp- the- HttpServletResponseobject that contains the response the servlet returns to the client
- Throws:
- java.io.IOException- if an input or output error occurs while the servlet is handling the OPTIONS request
- ServletException- if the request for the OPTIONS cannot be handled
 
 - 
determineMethodsAllowedprotected java.lang.String determineMethodsAllowed(HttpServletRequest req) 
 - 
sendNotAllowedprotected void sendNotAllowed(HttpServletRequest req, HttpServletResponse resp) throws java.io.IOException - Throws:
- java.io.IOException
 
 - 
doPostprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException Process a POST request for the specified resource.- Overrides:
- doPostin class- HttpServlet
- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet-specified error occurs
- See Also:
- ServletOutputStream,- ServletResponse.setContentType(java.lang.String)
 
 - 
doPutprotected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException Process a PUT request for the specified resource.- Overrides:
- doPutin class- HttpServlet
- Parameters:
- req- The servlet request we are processing
- resp- The servlet response we are creating
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet-specified error occurs
 
 - 
executePartialPutprotected java.io.File executePartialPut(HttpServletRequest req, DefaultServlet.Range range, java.lang.String path) throws java.io.IOException Handle a partial PUT. New content specified in request is appended to existing content in oldRevisionContent (if present). This code does not support simultaneous partial updates to the same resource.- Parameters:
- req- The Servlet request
- range- The range that will be written
- path- The path
- Returns:
- the associated file object
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
doDeleteprotected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException Process a DELETE request for the specified resource.- Overrides:
- doDeletein class- HttpServlet
- Parameters:
- req- The servlet request we are processing
- resp- The servlet response we are creating
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet-specified error occurs
 
 - 
checkIfHeadersprotected boolean checkIfHeaders(HttpServletRequest request, HttpServletResponse response, WebResource resource) throws java.io.IOException Check if the conditions specified in the optional If headers are satisfied.- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- resource- The resource
- Returns:
- trueif the resource meets all the specified conditions, and- falseif any of the conditions is not satisfied, in which case request processing is stopped
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
rewriteUrlprotected java.lang.String rewriteUrl(java.lang.String path) URL rewriter.- Parameters:
- path- Path which has to be rewritten
- Returns:
- the rewritten path
 
 - 
serveResourceprotected void serveResource(HttpServletRequest request, HttpServletResponse response, boolean content, java.lang.String inputEncoding) throws java.io.IOException, ServletException Serve the specified resource, optionally including the data content.- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- content- Should the content be included?
- inputEncoding- The encoding to use if it is necessary to access the source as characters rather than as bytes
- Throws:
- java.io.IOException- if an input/output error occurs
- ServletException- if a servlet-specified error occurs
 
 - 
parseContentRangeprotected DefaultServlet.Range parseContentRange(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException Parse the content-range header.- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- Returns:
- the partial content-range, nullif the content-range header was invalid or#IGNOREif there is no header to process
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
parseRangeprotected java.util.ArrayList<DefaultServlet.Range> parseRange(HttpServletRequest request, HttpServletResponse response, WebResource resource) throws java.io.IOException Parse the range header.- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- resource- The resource
- Returns:
- a list of ranges, nullif the range header was invalid or#FULLif the Range header should be ignored.
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
render@Deprecated protected java.io.InputStream render(java.lang.String contextPath, WebResource resource) throws java.io.IOException, ServletExceptionDeprecated.Unused. Will be removed in Tomcat 9Decide which way to render. HTML or XML.- Parameters:
- contextPath- The path
- resource- The resource
- Returns:
- the input stream with the rendered output
- Throws:
- java.io.IOException- an IO error occurred
- ServletException- rendering error
 
 - 
render@Deprecated protected java.io.InputStream render(java.lang.String contextPath, WebResource resource, java.lang.String encoding) throws java.io.IOException, ServletExceptionDeprecated.Decide which way to render. HTML or XML.- Parameters:
- contextPath- The path
- resource- The resource
- encoding- The encoding to use to process the readme (if any)
- Returns:
- the input stream with the rendered output
- Throws:
- java.io.IOException- an IO error occurred
- ServletException- rendering error
 
 - 
renderprotected java.io.InputStream render(HttpServletRequest request, java.lang.String contextPath, WebResource resource, java.lang.String encoding) throws java.io.IOException, ServletException Decide which way to render. HTML or XML.- Parameters:
- request- The HttpServletRequest being served
- contextPath- The path
- resource- The resource
- encoding- The encoding to use to process the readme (if any)
- Returns:
- the input stream with the rendered output
- Throws:
- java.io.IOException- an IO error occurred
- ServletException- rendering error
 
 - 
renderXml@Deprecated protected java.io.InputStream renderXml(java.lang.String contextPath, WebResource resource, javax.xml.transform.Source xsltSource) throws java.io.IOException, ServletExceptionDeprecated.Unused. Will be removed in Tomcat 9Return an InputStream to an XML representation of the contents this directory.- Parameters:
- contextPath- Context path to which our internal paths are relative
- resource- The associated resource
- xsltSource- The XSL stylesheet
- Returns:
- the XML data
- Throws:
- java.io.IOException- an IO error occurred
- ServletException- rendering error
 
 - 
renderXml@Deprecated protected java.io.InputStream renderXml(java.lang.String contextPath, WebResource resource, javax.xml.transform.Source xsltSource, java.lang.String encoding) throws ServletException, java.io.IOExceptionDeprecated.Unused. Will be removed in Tomcat 10Return an InputStream to an XML representation of the contents this directory.- Parameters:
- contextPath- Context path to which our internal paths are relative
- resource- The associated resource
- xsltSource- The XSL stylesheet
- encoding- The encoding to use to process the readme (if any)
- Returns:
- the XML data
- Throws:
- java.io.IOException- an IO error occurred
- ServletException- rendering error
 
 - 
renderXmlprotected java.io.InputStream renderXml(HttpServletRequest request, java.lang.String contextPath, WebResource resource, javax.xml.transform.Source xsltSource, java.lang.String encoding) throws java.io.IOException, ServletException Return an InputStream to an XML representation of the contents this directory.- Parameters:
- request- The HttpServletRequest being served
- contextPath- Context path to which our internal paths are relative
- resource- The associated resource
- xsltSource- The XSL stylesheet
- encoding- The encoding to use to process the readme (if any)
- Returns:
- the XML data
- Throws:
- java.io.IOException- an IO error occurred
- ServletException- rendering error
 
 - 
renderHtml@Deprecated protected java.io.InputStream renderHtml(java.lang.String contextPath, WebResource resource) throws java.io.IOExceptionDeprecated.Unused. Will be removed in Tomcat 9Return an InputStream to an HTML representation of the contents of this directory.- Parameters:
- contextPath- Context path to which our internal paths are relative
- resource- The associated resource
- Returns:
- the HTML data
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
renderHtml@Deprecated protected java.io.InputStream renderHtml(java.lang.String contextPath, WebResource resource, java.lang.String encoding) throws java.io.IOExceptionDeprecated.Unused. Will be removed in Tomcat 10Return an InputStream to an HTML representation of the contents of this directory.- Parameters:
- contextPath- Context path to which our internal paths are relative
- resource- The associated resource
- encoding- The encoding to use to process the readme (if any)
- Returns:
- the HTML data
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
renderHtmlprotected java.io.InputStream renderHtml(HttpServletRequest request, java.lang.String contextPath, WebResource resource, java.lang.String encoding) throws java.io.IOException Return an InputStream to an HTML representation of the contents of this directory.- Parameters:
- request- The HttpServletRequest being served
- contextPath- Context path to which our internal paths are relative
- resource- The associated resource
- encoding- The encoding to use to process the readme (if any)
- Returns:
- the HTML data
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
renderSizeprotected java.lang.String renderSize(long size) Render the specified file size (in bytes).- Parameters:
- size- File size (in bytes)
- Returns:
- the formatted size
 
 - 
getReadme@Deprecated protected java.lang.String getReadme(WebResource directory) Deprecated.Unused. Will be removed in Tomcat 9Get the readme file as a string.- Parameters:
- directory- The directory to search
- Returns:
- the readme for the specified directory
 
 - 
getReadmeprotected java.lang.String getReadme(WebResource directory, java.lang.String encoding) Get the readme file as a string.- Parameters:
- directory- The directory to search
- encoding- The readme encoding
- Returns:
- the readme for the specified directory
 
 - 
findXsltSourceprotected javax.xml.transform.Source findXsltSource(WebResource directory) throws java.io.IOException Return a Source for the xsl template (if possible).- Parameters:
- directory- The directory to search
- Returns:
- the source for the specified directory
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
checkSendfileprotected boolean checkSendfile(HttpServletRequest request, HttpServletResponse response, WebResource resource, long length, DefaultServlet.Range range) Check if sendfile can be used.- Parameters:
- request- The Servlet request
- response- The Servlet response
- resource- The resource
- length- The length which will be written (will be used only if range is null)
- range- The range that will be written
- Returns:
- trueif sendfile should be used (writing is then delegated to the endpoint)
 
 - 
checkIfMatchprotected boolean checkIfMatch(HttpServletRequest request, HttpServletResponse response, WebResource resource) throws java.io.IOException Check if the if-match condition is satisfied.- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- resource- The resource
- Returns:
- trueif the resource meets the specified condition, and- falseif the condition is not satisfied, in which case request processing is stopped
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
checkIfModifiedSinceprotected boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response, WebResource resource) Check if the if-modified-since condition is satisfied.- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- resource- The resource
- Returns:
- trueif the resource meets the specified condition, and- falseif the condition is not satisfied, in which case request processing is stopped
 
 - 
checkIfNoneMatchprotected boolean checkIfNoneMatch(HttpServletRequest request, HttpServletResponse response, WebResource resource) throws java.io.IOException Check if the if-none-match condition is satisfied.- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- resource- The resource
- Returns:
- trueif the resource meets the specified condition, and- falseif the condition is not satisfied, in which case request processing is stopped
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
checkIfUnmodifiedSinceprotected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response, WebResource resource) throws java.io.IOException Check if the if-unmodified-since condition is satisfied.- Parameters:
- request- The servlet request we are processing
- response- The servlet response we are creating
- resource- The resource
- Returns:
- trueif the resource meets the specified condition, and- falseif the condition is not satisfied, in which case request processing is stopped
- Throws:
- java.io.IOException- an IO error occurred
 
 - 
generateETagprotected java.lang.String generateETag(WebResource resource) Provides the entity tag (the ETag header) for the given resource. Intended to be over-ridden by custom DefaultServlet implementations that wish to use an alternative format for the entity tag.- Parameters:
- resource- The resource for which an entity tag is required.
- Returns:
- The result of calling WebResource.getETag()on the given resource
 
 - 
copy@Deprecated protected void copy(WebResource resource, java.io.InputStream is, ServletOutputStream ostream) throws java.io.IOException Deprecated.Unused. This will be removed in Tomcat 9. Usecopy(InputStream, ServletOutputStream)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).- Parameters:
- resource- The source resource
- is- The input stream to read the source resource from
- ostream- The output stream to write to
- Throws:
- java.io.IOException- if an input/output error occurs
 
 - 
copyprotected void copy(java.io.InputStream is, ServletOutputStream ostream) throws java.io.IOExceptionCopy 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).- Parameters:
- is- The input stream to read the source resource from
- ostream- The output stream to write to
- Throws:
- java.io.IOException- if an input/output error occurs
 
 - 
copy@Deprecated protected void copy(WebResource resource, java.io.InputStream is, java.io.PrintWriter writer, java.lang.String encoding) throws java.io.IOException Deprecated.Unused. This will be removed in Tomcat 9. Usecopy(InputStream, PrintWriter, String)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).- Parameters:
- resource- The source resource
- is- The input stream to read the source resource from
- writer- The writer to write to
- encoding- The encoding to use when reading the source input stream
- Throws:
- java.io.IOException- if an input/output error occurs
 
 - 
copyprotected void copy(java.io.InputStream is, java.io.PrintWriter writer, java.lang.String encoding) throws java.io.IOExceptionCopy 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).- Parameters:
- is- The input stream to read the source resource from
- writer- The writer to write to
- encoding- The encoding to use when reading the source input stream
- Throws:
- java.io.IOException- if an input/output error occurs
 
 - 
copyprotected void copy(WebResource resource, ServletOutputStream ostream, DefaultServlet.Range range) throws java.io.IOException 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).- Parameters:
- resource- The source resource
- ostream- The output stream to write to
- range- Range the client wanted to retrieve
- Throws:
- java.io.IOException- if an input/output error occurs
 
 - 
copyprotected void copy(WebResource resource, ServletOutputStream ostream, java.util.Iterator<DefaultServlet.Range> ranges, java.lang.String contentType) throws java.io.IOException 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).- Parameters:
- resource- The source resource
- ostream- The output stream to write to
- ranges- Enumeration of the ranges the client wanted to retrieve
- contentType- Content type of the resource
- Throws:
- java.io.IOException- if an input/output error occurs
 
 - 
copyRangeprotected java.io.IOException copyRange(java.io.InputStream istream, 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).- Parameters:
- istream- The input stream to read from
- ostream- The output stream to write to
- Returns:
- Exception which occurred during processing
 
 - 
copyRangeprotected 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).- Parameters:
- reader- The reader to read from
- writer- The writer to write to
- Returns:
- Exception which occurred during processing
 
 - 
copyRangeprotected java.io.IOException copyRange(java.io.InputStream istream, 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).- Parameters:
- istream- The input stream to read from
- ostream- The output stream to write to
- start- Start of the range which will be copied
- end- End of the range which will be copied
- Returns:
- Exception which occurred during processing
 
 
- 
 
-