Class FrontendServlet

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

    public class FrontendServlet
    extends javax.servlet.http.HttpServlet
    This is a servlet that's intended to be a base class for a DS component exposing a Servlet service that plugs into the OSGi web whiteboard. The servlet will scan the classpath for resources matching the request pathinfo (minus any webcontext added to the servlet path) and serve the resources with a content-type determined by the file name extension. In addition the servlet supports a list of aliases for index.html that exists to support reload of paths created by the react router. In a subclass, this list can be set by calling the setRoutes(String...) method.
    See Also:
    Serialized Form
    • Field Detail

      • logservice

        private final no.priv.bang.osgi.service.adapters.logservice.LogServiceAdapter logservice
    • Constructor Detail

      • FrontendServlet

        public FrontendServlet()
    • Method Detail

      • setRoutes

        public void setRoutes​(String... routes)
      • setLogService

        public void setLogService​(org.osgi.service.log.LogService logservice)
      • doGet

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

        String guessContentTypeFromResourceName​(String resource)
      • findResourceFromPathInfo

        private String findResourceFromPathInfo​(String pathInfo)
      • addSlashToServletPath

        private void addSlashToServletPath​(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
                                    throws IOException
        Throws:
        IOException