Class AbstractResourceHandler

java.lang.Object
spark.resource.AbstractResourceHandler
Direct Known Subclasses:
ClassPathResourceHandler, ExternalResourceHandler

public abstract class AbstractResourceHandler extends 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.
  • Field Details

  • Constructor Details

    • AbstractResourceHandler

      public AbstractResourceHandler()
  • Method Details

    • getResource

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

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

      public static String addPaths(String segment1, 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.