public class DefaultServlet
extends javax.servlet.http.HttpServlet
Modifier and Type | Class and Description |
---|---|
protected class |
DefaultServlet.Range |
Modifier and Type | Field and Description |
---|---|
protected static int |
BUFFER_SIZE
Size of file transfer buffer in bytes.
|
protected String |
contextXsltFile
Allow customized directory listing per context.
|
protected int |
debug
The debugging detail level for this servlet.
|
protected String |
fileEncoding
File encoding to be used when reading static files.
|
protected static ArrayList<DefaultServlet.Range> |
FULL
Full range marker.
|
protected 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 String |
localXsltFile
Allow customized directory listing per directory.
|
protected static String |
mimeSeparation
MIME multipart separation string
|
protected int |
output
The output buffer size to use when serving resources.
|
protected String |
readmeFile
Allow a readme file to be included.
|
protected boolean |
readOnly
Read only flag.
|
protected ProxyDirContext |
resources
Proxy directory context.
|
protected static String |
RESOURCES_JNDI_NAME
JNDI resources name.
|
protected int |
sendfileSize
Minimum size for sendfile usage in bytes.
|
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 and Description |
---|
DefaultServlet() |
Modifier and Type | Method and Description |
---|---|
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,
String path,
CacheEntry entry,
long length,
DefaultServlet.Range range)
Check if sendfile can be used.
|
protected void |
copy(CacheEntry cacheEntry,
InputStream is,
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,
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,
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,
PrintWriter writer,
Iterator<DefaultServlet.Range> ranges,
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,
Iterator<DefaultServlet.Range> ranges,
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 IOException |
copyRange(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 IOException |
copyRange(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 IOException |
copyRange(Reader reader,
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 IOException |
copyRange(Reader reader,
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(StringBuilder 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 |
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 File |
executePartialPut(javax.servlet.http.HttpServletRequest req,
DefaultServlet.Range range,
String path)
Handle a partial PUT.
|
protected InputStream |
findXsltInputStream(DirContext directory)
Return the xsl template inputstream (if possible)
|
protected String |
getReadme(DirContext directory)
Get the readme file as a string.
|
protected String |
getRelativePath(javax.servlet.http.HttpServletRequest request)
Return the relative path associated with this servlet.
|
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 ArrayList<DefaultServlet.Range> |
parseRange(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ResourceAttributes resourceAttributes)
Parse the range header.
|
protected InputStream |
render(String contextPath,
CacheEntry cacheEntry)
Decide which way to render.
|
protected InputStream |
renderHtml(String contextPath,
CacheEntry cacheEntry)
Return an InputStream to an HTML representation of the contents
of this directory.
|
protected String |
renderSize(long size)
Render the specified file size (in bytes).
|
protected InputStream |
renderXml(String contextPath,
CacheEntry cacheEntry,
InputStream xsltInputStream)
Return an InputStream to an HTML representation of the contents
of this directory.
|
protected String |
rewriteUrl(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.
|
doOptions, doTrace, getLastModified, service, service
protected int debug
protected int input
protected boolean listings
protected boolean readOnly
protected int output
protected static URLEncoder urlEncoder
protected String localXsltFile
protected String contextXsltFile
protected String globalXsltFile
protected String readmeFile
protected ProxyDirContext resources
protected String fileEncoding
protected int sendfileSize
protected boolean useAcceptRanges
protected static ArrayList<DefaultServlet.Range> FULL
protected static final String mimeSeparation
protected static final String RESOURCES_JNDI_NAME
protected static final int BUFFER_SIZE
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
protected String getRelativePath(javax.servlet.http.HttpServletRequest request)
request
- The servlet request we are processingprotected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
doGet
in class javax.servlet.http.HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creatingIOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet-specified error occursprotected void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
doHead
in class javax.servlet.http.HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creatingIOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet-specified error occursprotected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
doPost
in class javax.servlet.http.HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creatingIOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet-specified error occursprotected void doPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException
doPut
in class javax.servlet.http.HttpServlet
req
- The servlet request we are processingresp
- The servlet response we are creatingIOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet-specified error occursprotected File executePartialPut(javax.servlet.http.HttpServletRequest req, DefaultServlet.Range range, String path) throws IOException
IOException
protected void doDelete(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException
doDelete
in class javax.servlet.http.HttpServlet
req
- The servlet request we are processingresp
- The servlet response we are creatingIOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet-specified error occursprotected boolean checkIfHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceAttributes
- The resource informationIOException
protected String rewriteUrl(String path)
path
- Path which has to be rewitenprotected void displaySize(StringBuilder buf, int filesize)
protected void serveResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean content) throws IOException, javax.servlet.ServletException
request
- The servlet request we are processingresponse
- The servlet response we are creatingcontent
- Should the content be included?IOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet-specified error occursprotected DefaultServlet.Range parseContentRange(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingIOException
protected ArrayList<DefaultServlet.Range> parseRange(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingIOException
protected InputStream render(String contextPath, CacheEntry cacheEntry) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
protected InputStream renderXml(String contextPath, CacheEntry cacheEntry, InputStream xsltInputStream) throws IOException, javax.servlet.ServletException
contextPath
- Context path to which our internal paths are
relativeIOException
javax.servlet.ServletException
protected InputStream renderHtml(String contextPath, CacheEntry cacheEntry) throws IOException, javax.servlet.ServletException
contextPath
- Context path to which our internal paths are
relativeIOException
javax.servlet.ServletException
protected String renderSize(long size)
size
- File size (in bytes)protected String getReadme(DirContext directory) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
protected InputStream findXsltInputStream(DirContext directory) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
protected boolean checkSendfile(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String path, CacheEntry entry, long length, DefaultServlet.Range range)
protected boolean checkIfMatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceInfo
- File objectIOException
protected boolean checkIfModifiedSince(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceInfo
- File objectIOException
protected boolean checkIfNoneMatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceInfo
- File objectIOException
protected boolean checkIfUnmodifiedSince(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ResourceAttributes resourceAttributes) throws IOException
request
- The servlet request we are processingresponse
- The servlet response we are creatingresourceInfo
- File objectIOException
protected void copy(CacheEntry cacheEntry, InputStream is, javax.servlet.ServletOutputStream ostream) throws IOException
resourceInfo
- The resource informationostream
- The output stream to write toIOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, InputStream is, PrintWriter writer) throws IOException
resourceInfo
- The resource infowriter
- The writer to write toIOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, javax.servlet.ServletOutputStream ostream, DefaultServlet.Range range) throws IOException
resourceInfo
- The ResourceInfo objectostream
- The output stream to write torange
- Range the client wanted to retrieveIOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, PrintWriter writer, DefaultServlet.Range range) throws IOException
resourceInfo
- The ResourceInfo objectwriter
- The writer to write torange
- Range the client wanted to retrieveIOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, javax.servlet.ServletOutputStream ostream, Iterator<DefaultServlet.Range> ranges, String contentType) throws IOException
resourceInfo
- The ResourceInfo objectostream
- The output stream to write toranges
- Enumeration of the ranges the client wanted to retrievecontentType
- Content type of the resourceIOException
- if an input/output error occursprotected void copy(CacheEntry cacheEntry, PrintWriter writer, Iterator<DefaultServlet.Range> ranges, String contentType) throws IOException
resourceInfo
- The ResourceInfo objectwriter
- The writer to write toranges
- Enumeration of the ranges the client wanted to retrievecontentType
- Content type of the resourceIOException
- if an input/output error occursprotected IOException copyRange(InputStream istream, javax.servlet.ServletOutputStream ostream)
istream
- The input stream to read fromostream
- The output stream to write toprotected IOException copyRange(Reader reader, PrintWriter writer)
reader
- The reader to read fromwriter
- The writer to write toprotected IOException copyRange(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 copiedprotected IOException copyRange(Reader reader, 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 copiedCopyright © 2013 JBoss, a division of Red Hat, Inc.. All rights reserved.