Package alpine.servlets
Class StaticResourceServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- alpine.servlets.StaticResourceServlet
-
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
- Direct Known Subclasses:
FileSystemResourceServlet
public abstract class StaticResourceServlet extends javax.servlet.http.HttpServletThe StaticResourceServlet provides a foundation in which to serve static resources similar to a conventional web server. This class is designed to be extended to provide specific functionality. Adapted from http://stackoverflow.com/questions/132052/servlet-for-serving-static-content- Since:
- 1.2.0
- Author:
- Steve Springett
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StaticResourceServlet()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected voiddoHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected abstract alpine.servlets.StaticResourcegetStaticResource(javax.servlet.http.HttpServletRequest request)Returns the static resource associated with the given HTTP servlet request.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service
-
-
-
-
Method Detail
-
doHead
protected void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException- 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, IOException- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
getStaticResource
protected abstract alpine.servlets.StaticResource getStaticResource(javax.servlet.http.HttpServletRequest request) throws IllegalArgumentExceptionReturns the static resource associated with the given HTTP servlet request. This returnsnullwhen the resource does actually not exist. The servlet will then return a HTTP 404 error.- Parameters:
request- The involved HTTP servlet request.- Returns:
- The static resource associated with the given HTTP servlet request.
- Throws:
IllegalArgumentException- When the request is mangled in such way that it's not recognizable as a valid static resource request. The servlet will then return a HTTP 400 error.
-
-