Package org.javlo.servlet
Class FileServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.javlo.servlet.FileServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
- Direct Known Subclasses:
ImageTransformServlet
public class FileServlet extends javax.servlet.http.HttpServlet
A file servlet supporting resume of downloads and client-side caching and GZIP of text content. This servlet can also be used for images, client-side caching would become more efficient. This servlet can also be used for text files, GZIP would decrease network bandwidth.- Author:
- BalusC
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
FileServlet.Range
This class represents a byte range.
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_EXPIRE_TIME
-
Constructor Summary
Constructors Constructor Description FileServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Process GET request.protected void
doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Process HEAD request.static boolean
matches(String matchHeader, String toMatch)
Returns true if the given match header matches the given value.protected void
processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean content)
protected void
processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, File file, boolean content)
Process the actual request.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
DEFAULT_EXPIRE_TIME
public static final long DEFAULT_EXPIRE_TIME
- See Also:
- Constant Field Values
-
-
Method Detail
-
doHead
protected void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
Process HEAD request. This returns the same headers as GET request, but without content.- Overrides:
doHead
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
IOException
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
Process GET request.- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
IOException
-
processRequest
protected void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean content) throws IOException
- Throws:
IOException
-
processRequest
protected void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, File file, boolean content) throws IOException
Process the actual request.- Parameters:
request
- The request to be processed.response
- The response to be created.content
- Whether the request body should be written (GET) or not (HEAD).- Throws:
IOException
- If something fails at I/O level.
-
-