Class AbstractResourceHandler

  • Direct Known Subclasses:
    ClassPathResourceHandler, ExternalResourceHandler

    public abstract class AbstractResourceHandler
    extends java.lang.Object
    Abstract class providing functionality for finding resources based on an Http Servlet request. Code snippets copied from Eclipse Jetty source. Modifications made by Per Wendel.
    • Constructor Detail

      • AbstractResourceHandler

        public AbstractResourceHandler()
    • Method Detail

      • getResource

        public AbstractFileResolvingResource getResource​(javax.servlet.http.HttpServletRequest request)
                                                  throws java.net.MalformedURLException
        Gets a resource from a servlet request
        Parameters:
        request - the servlet request
        Returns:
        the resource or null if not found
        Throws:
        java.net.MalformedURLException - thrown when malformed URL.
      • getResource

        protected abstract AbstractFileResolvingResource getResource​(java.lang.String path)
                                                              throws java.net.MalformedURLException
        Gets resource from path
        Parameters:
        path - the path
        Returns:
        the resource or null if resource doesn't exist
        Throws:
        java.net.MalformedURLException - thrown when malformed URL.
      • addPaths

        public static java.lang.String addPaths​(java.lang.String segment1,
                                                java.lang.String segment2)
        Add two URI path segments. Handles null and empty paths, path and query params (eg ?a=b or ;JSESSIONID=xxx) and avoids duplicate '/'
        Parameters:
        segment1 - URI path segment (should be encoded)
        segment2 - URI path segment (should be encoded)
        Returns:
        Legally combined path segments.