The default resource-serving servlet for most web applications,
used to serve static resources such as HTML pages and images.
RESOURCES_JNDI_NAME
protected static final String RESOURCES_JNDI_NAME
JNDI resources name.
debug
protected int debug
The debugging detail level for this servlet.
globalXsltFile
protected String globalXsltFile
Allow customized directory listing per instance.
input
protected int input
The input buffer size to use when serving resources.
listings
protected boolean listings
Should we generate directory listings?
localXsltFile
protected String localXsltFile
Allow customized directory listing per directory.
md5Encoder
protected static final MD5Encoder md5Encoder
The MD5 helper object for this class.
md5Helper
protected static MessageDigest md5Helper
MD5 message digest provider.
mimeSeparation
protected static final String mimeSeparation
MIME multipart separation string
output
protected int output
The output buffer size to use when serving resources.
readOnly
protected boolean readOnly
Read only flag. By default, it's set to true.
readmeFile
protected String readmeFile
Allow a readme file to be included.
sm
protected static StringManager sm
The string manager for this package.
urlEncoder
protected static URLEncoder urlEncoder
Array containing the safe characters set.
appendParameters
protected String appendParameters(HttpServletRequest request,
String redirectPath)
Append the request parameters to the redirection string before calling
sendRedirect.
checkIfHeaders
protected boolean checkIfHeaders(HttpServletRequest request,
HttpServletResponse response,
DefaultServlet.ResourceInfo resourceInfo)
throws IOException
Check if the conditions specified in the optional If headers are
satisfied.
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceInfo
- File object
- boolean true if the resource meets all the specified conditions,
and false if any of the conditions is not satisfied, in which case
request processing is stopped
destroy
public void destroy()
Finalize this servlet.
displaySize
protected void displaySize(StringBuffer buf,
int filesize)
Display the size of a file.
doDelete
protected void doDelete(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
Process a POST request for the specified resource.
doGet
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException,
ServletException
Process a GET request for the specified resource.
request
- The servlet request we are processingresponse
- The servlet response we are creating
doHead
protected void doHead(HttpServletRequest request,
HttpServletResponse response)
throws IOException,
ServletException
Process a HEAD request for the specified resource.
request
- The servlet request we are processingresponse
- The servlet response we are creating
doPost
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException,
ServletException
Process a POST request for the specified resource.
request
- The servlet request we are processingresponse
- The servlet response we are creating
doPut
protected void doPut(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
Process a POST request for the specified resource.
req
- The servlet request we are processingresp
- The servlet response we are creating
executePartialPut
protected File executePartialPut(HttpServletRequest req,
org.apache.catalina.servlets.DefaultServlet.Range range,
String path)
throws 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.
findXsltInputStream
protected InputStream findXsltInputStream(DirContext directory)
Return the xsl template inputstream (if possible)
getETag
protected String getETag(DefaultServlet.ResourceInfo resourceInfo)
Get the ETag associated with a file.
resourceInfo
- File object
getReadme
protected String getReadme(DirContext directory)
Get the readme file as a string.
getRelativePath
protected String getRelativePath(HttpServletRequest request)
Return the relative path associated with this servlet.
request
- The servlet request we are processing
getResources
protected DirContext getResources()
Get resources. This method will try to retrieve the resources through
JNDI first, then in the servlet context if JNDI has failed (it could be
disabled). It will return null.
- A JNDI DirContext, or null.
init
public void init()
throws ServletException
Initialize this servlet.
normalize
protected String normalize(String path)
Return a context-relative path, beginning with a "/", that represents
the canonical version of the specified path after ".." and "." elements
are resolved out. If the specified path attempts to go outside the
boundaries of the current context (i.e. too many ".." path elements
are present), return null
instead.
path
- Path to be normalized
parseContentRange
protected org.apache.catalina.servlets.DefaultServlet.Range parseContentRange(HttpServletRequest request,
HttpServletResponse response)
throws IOException
Parse the content-range header.
request
- The servlet request we are processingresponse
- The servlet response we are creating
- Range
parseRange
protected Vector parseRange(HttpServletRequest request,
HttpServletResponse response,
DefaultServlet.ResourceInfo resourceInfo)
throws IOException
Parse the range header.
request
- The servlet request we are processingresponse
- The servlet response we are creating
- Vector of ranges
render
protected InputStream render(String contextPath,
DefaultServlet.ResourceInfo resourceInfo)
Decide which way to render. HTML or XML.
renderHtml
protected InputStream renderHtml(String contextPath,
DefaultServlet.ResourceInfo resourceInfo)
Return an InputStream to an HTML representation of the contents
of this directory.
contextPath
- Context path to which our internal paths are
relative
renderSize
protected String renderSize(long size)
Render the specified file size (in bytes).
size
- File size (in bytes)
renderXml
protected InputStream renderXml(String contextPath,
DefaultServlet.ResourceInfo resourceInfo,
InputStream xsltInputStream)
Return an InputStream to an HTML representation of the contents
of this directory.
contextPath
- Context path to which our internal paths are
relative
rewriteUrl
protected String rewriteUrl(String path)
URL rewriter.
path
- Path which has to be rewiten
serveResource
protected void serveResource(HttpServletRequest request,
HttpServletResponse response,
boolean content)
throws IOException,
ServletException
Serve the specified resource, optionally including the data content.
request
- The servlet request we are processingresponse
- The servlet response we are creatingcontent
- Should the content be included?
showRequestInfo
protected void showRequestInfo(HttpServletRequest req)
Show HTTP header information.