Class StaticResourceServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
de.businesscode.bcdui.web.servlets.StaticResourceServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class StaticResourceServlet extends jakarta.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:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    This class represents one single resource which is either a file on the file system or a URL from the classpath.
    static interface 
    resource abstract descriptor implementing API to the content
    static interface 
    provider interface to resolve a StaticResourceServlet.Resource
    static class 
    a static resource provider singleton
  • Field Summary

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Implementation of GET requests.
    protected void
    doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
     
    void
    init(jakarta.servlet.ServletConfig config)
     

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPatch, doPut, doTrace, getLastModified, isSensitiveHeader, service, service

    Methods inherited from class jakarta.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 Details

    • StaticResourceServlet

      public StaticResourceServlet()
  • Method Details

    • init

      public void init(jakarta.servlet.ServletConfig config) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Servlet
      Overrides:
      init in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
    • doGet

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

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