Class UrlHandler

java.lang.Object
org.bedework.webdav.servlet.shared.UrlHandler
All Implemented Interfaces:
UrlPrefixer, UrlUnprefixer

public class UrlHandler extends Object implements UrlPrefixer, UrlUnprefixer
Prefix or unprefix urls - or not depending on internal state
Author:
douglm
  • Constructor Details

    • UrlHandler

      public UrlHandler(javax.servlet.http.HttpServletRequest req, boolean relative)
      If relative we assume urls are relative to the host + port. Internally we need to strip off the host + port + context.
      Parameters:
      req - the incoming request
      relative - true for relative urls
    • UrlHandler

      public UrlHandler(String urlPrefix, String context, boolean relative)
      Parameters:
      urlPrefix - Usually host + port + "/" e.g. example.com:8080/
      context - null, zero length or the servlet context, e.g. caldav
      relative - true if we want relative (to the server) urls
  • Method Details

    • prefix

      public String prefix(String val)
      Description copied from interface: UrlPrefixer
      Return an appropriately prefixed url. The parameter url will be absolute or relative. If relative it may be prefixed with the context path which we need to remove.

      We're doing this because some clients don't handle absolute urls (a violation of the spec)

      Specified by:
      prefix in interface UrlPrefixer
      Parameters:
      val - to prefix
      Returns:
      String
    • unprefix

      public String unprefix(String val)
      Description copied from interface: UrlUnprefixer
      Remove any vestige of the host, port or context
      Specified by:
      unprefix in interface UrlUnprefixer
      Parameters:
      val - to unprefix
      Returns:
      String
    • getUrlPrefix

      public String getUrlPrefix()
      Returns:
      String url prefix (host + port, no context)