Interface BaseURLSource

All Known Implementing Classes:

public interface BaseURLSource

Used when switching between normal/insecure (HTTP) and secure (HTTPS) mode. When a switch occurs, it is no longer possible to use just paths, instead absolute URLs (including the scheme, hostname and possibly port) must be generated. The default implementation of this is simple-minded: it just tacks the correct scheme in front of Request.getServerName(). In production, behind a firewall, it is often necessary to do a bit more, since getServerName() will often be the name of the internal server (not visible to the client web browser), and a hard-coded name of a server that is visible to the web browser is needed. Further, in testing, non-default ports are often used. In those cases, an overriding contribution to the ServiceOverride service will allow a custom implementation to supercede the default version. You may also contribute application specific values for the following SymbolConstants: SymbolConstants.HOSTNAME, SymbolConstants.HOSTPORT and SymbolConstants.HOSTPORT_SECURE to alter the behavior of the default BaseURLSource implementation. The default values for the SymbolConstants require Request context to be available. If you contribute specific values for the specified SymbolConstants, it's safe to use the default implementation of this service outside of request context, for example in a batch job. For SymbolConstants.HOSTNAME, a value starting with a dollar sign ($) will be resolved using System.getenv() - contributing "$HOSTNAME" for SymbolConstants.HOSTNAME is the most sensible choice for a dynamic value that doesn't use Request.getServerName().

Method Summary
 String getBaseURL(boolean secure)
          Returns the base portion of the URL, before the context path and servlet path are appended.

Method Detail


String getBaseURL(boolean secure)
Returns the base portion of the URL, before the context path and servlet path are appended. The return value should not end with a slash; it should end after the host name, or after the port number. The context path, servlet path, and path info will be appended to the returned value.

secure - whether a secure "https" or insecure "http" base URL should be returned
the base URL ready for additional extensions

Copyright © 2003-2012 The Apache Software Foundation.