Class MovedContextHandler

All Implemented Interfaces:
AliasCheck, Handler, Handler.Container, Handler.Singleton, Request.Handler, Attributes, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, Invocable

public class MovedContextHandler extends ContextHandler

A ContextHandler with a child Handler that redirects to a configurable URI.

  • Constructor Details

    • MovedContextHandler

      public MovedContextHandler()
  • Method Details

    • getStatusCode

      public int getStatusCode()
      Get the redirect status code, by default 303.
      Returns:
      the redirect status code, by default 303
    • setStatusCode

      public void setStatusCode(int statusCode)
      Parameters:
      statusCode - the redirect status code
      Throws:
      IllegalArgumentException - if the status code is not of type redirect (3xx)
    • getRedirectURI

      public String getRedirectURI()
      Get the URI to redirect to.
      Returns:
      the URI to redirect to
    • setRedirectURI

      public void setRedirectURI(String redirectURI)

      Sets the URI to redirect to.

      If the redirect URI is not absolute, the original request scheme and authority will be used to build the redirect URI.

      The original request pathInContext will be appended to the redirect URI path, unless isDiscardPathInContext().

      The original request query will be preserved in the redirect URI, unless isDiscardQuery().

      Parameters:
      redirectURI - the URI to redirect to
    • isDiscardPathInContext

      public boolean isDiscardPathInContext()
      Returns:
      whether the original request pathInContext is discarded
    • setDiscardPathInContext

      public void setDiscardPathInContext(boolean discardPathInContext)

      Whether to discard the original request pathInContext when building the redirect URI.

      Parameters:
      discardPathInContext - whether the original request pathInContext is discarded
      See Also:
    • isDiscardQuery

      public boolean isDiscardQuery()
      Returns:
      whether the original request query is discarded
    • setDiscardQuery

      public void setDiscardQuery(boolean discardQuery)

      Whether to discard the original request query when building the redirect URI.

      Parameters:
      discardQuery - whether the original request query is discarded
    • getCacheControl

      public String getCacheControl()
      Get the Cache-Control header value or null.
      Returns:
      the Cache-Control header value or null
    • setCacheControl

      public void setCacheControl(String cacheControl)
      Set the Cache-Control header value or null.
      Parameters:
      cacheControl - the Cache-Control header value or null