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.HttpServletA 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 classFileServlet.RangeThis class represents a byte range.
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_EXPIRE_TIME
-
Constructor Summary
Constructors Constructor Description FileServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Process GET request.protected voiddoHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Process HEAD request.static booleanmatches(String matchHeader, String toMatch)Returns true if the given match header matches the given value.protected voidprocessRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean content)protected voidprocessRequest(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, IOExceptionProcess HEAD request. This returns the same headers as GET request, but without content.- Overrides:
doHeadin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOExceptionProcess GET request.- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
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 IOExceptionProcess 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.
-
-