Class StaticContentServlet

  • All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public final class StaticContentServlet
    extends HttpServlet
    A minimal servlet that can serve static files. Also from outside the web application.
    Version:
    $Id: StaticContentServlet.java,v 1.0 12.12.11 15:09 haraldk Exp$
    Author:
    Harald Kuhr, last modified by $Author: haraldk$
    See Also:
    setRoot(java.io.File), Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doGet​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)  
      protected long getLastModified​(javax.servlet.http.HttpServletRequest request)  
      void init()  
      void setRoot​(java.io.File root)
      Configures the file system root for this servlet.
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doHead, doOptions, doPost, doPut, doTrace, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StaticContentServlet

        public StaticContentServlet()
    • Method Detail

      • setRoot

        @InitParam(name="root")
        public void setRoot​(java.io.File root)
        Configures the file system root for this servlet. If root is a directory, files will be served relative to the directory. If root is a file, only this file may be served
        Parameters:
        root - the file system root.
      • init

        public void init()
                  throws javax.servlet.ServletException
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
      • getLastModified

        protected long getLastModified​(javax.servlet.http.HttpServletRequest request)
        Overrides:
        getLastModified in class javax.servlet.http.HttpServlet
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws java.io.IOException
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        java.io.IOException