Class ResourceServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
    Direct Known Subclasses:
    SiteStaticDirectoryServlet

    public abstract class ResourceServlet
    extends javax.servlet.http.HttpServlet
    Base class for serving static resources.

    Supports caching, ETags, basic content type detection, and limited gzip compression.

    See Also:
    Serialized Form
    • Constructor Detail

      • ResourceServlet

        protected ResourceServlet​(com.google.common.cache.Cache<Path,​ResourceServlet.Resource> cache,
                                  boolean refresh,
                                  boolean cacheOnClient)
    • Method Detail

      • contentType

        protected static String contentType​(String name)
      • getResourcePath

        protected abstract Path getResourcePath​(String pathInfo)
                                         throws IOException
        Get the resource path on the filesystem that should be served for this request.
        Parameters:
        pathInfo - result of HttpServletRequest.getPathInfo().
        Returns:
        path where static content can be found.
        Throws:
        IOException - if an error occurred resolving the resource.
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse rsp)
                      throws IOException
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        IOException