Class StaticResourceServlet

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

    public class StaticResourceServlet
    extends javax.servlet.http.HttpServlet
    This class enables the use of the database-backed virtual file system and jar files as source for seemingly static resources. Normal static files are located on the filesystem within the webapps root, put there when the server extracts the app.war file. Static files are requested by /appContext/some/path/someFile.txt for example. This class makes files under such an address available, which really come from the database or a jar (and classpath in general) within the app.war instead. Main usage is the virtual file system and making BCD-UI static files like js and xslt available from bcd-ui-core.jar within app.war. The search order is: First vfs, then file system (on server this is normal file from the war), then jar files. Note: Since vfs caches the file list from the database (not the actual content), a lookup in vfs is no performance hit. <servlet> <servlet-name>staticResourceServlet</servlet-name> <servlet-class>de.businesscode.web.StaticResourceServlet</servlet-class> <init-param> <param-name>vfsFileExtensions</param-name> <!-- Extensions that can be overwritten in vfs --> <param-value>xml txt vfsxml pdf png gif jpg jpeg svg doc docx xls xlsx csv zip</param-value> </init-param> </servlet> <!-- Add any URL for the virtual file system here --> <servlet-mapping> <servlet-name>bcdui4.StaticResourceServlet</servlet-name> <url-pattern>/bcdui/*</url-pattern> <url-pattern>/vfs/*</url-pattern> <url-pattern>*.vfsxml</url-pattern> </servlet-mapping>
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doGet​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Implementation of GET requests.
      protected void doPost​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)  
      void init​(javax.servlet.ServletConfig config)  
      • Methods inherited from class javax.servlet.http.HttpServlet

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

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

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

      • StaticResourceServlet

        public StaticResourceServlet()
    • Method Detail

      • init

        public void init​(javax.servlet.ServletConfig config)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Servlet
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse resp)
                      throws javax.servlet.ServletException,
                             java.io.IOException
        Implementation of GET requests.
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • doPost

        protected void doPost​(javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse resp)
                       throws javax.servlet.ServletException,
                              java.io.IOException
        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        java.io.IOException