org.hippoecm.hst.util
Class HstRequestUtils

java.lang.Object
  extended by org.hippoecm.hst.util.HstRequestUtils

public class HstRequestUtils
extends Object

HST Request Utils

Version:
$Id: HstRequestUtils.java 34865 2012-06-27 18:22:04Z wko $

Method Summary
static String getFarthestRemoteAddr(javax.servlet.http.HttpServletRequest request)
          Returns the remote client address.
static String getFarthestRequestHost(javax.servlet.http.HttpServletRequest request)
          Returns the original host information requested by the client.
static String getFarthestRequestHost(javax.servlet.http.HttpServletRequest request, boolean checkRenderHost)
          Returns the original host information requested by the client and do check optional injected render host information only when checkRenderHost is true
static HstRequest getHstRequest(javax.servlet.http.HttpServletRequest servletRequest)
          Returns HstRequest object found in the servletRequest.
static HstRequestContext getHstRequestContext(javax.servlet.http.HttpServletRequest servletRequest)
          Returns HstRequestContext object found in the servletRequest.
static HstResponse getHstResponse(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse)
          Returns HstResponse object found in the servletRequest or servletResponse.
static String getPathInfo(ResolvedMount mount, javax.servlet.http.HttpServletRequest request)
          Returns any extra path information associated with the URL the client sent when it made this request.
static String getPathInfo(ResolvedMount mount, javax.servlet.http.HttpServletRequest request, String characterEncoding)
           Returns any extra path information associated with the URL the client sent when it made this request.
static String[] getRemoteAddrs(javax.servlet.http.HttpServletRequest request)
          Returns the remote host addresses related to this request.
static String getRenderingHost(javax.servlet.http.HttpServletRequest request)
          Returns the rendering host of the current request, i.e.
static String[] getRequestHosts(javax.servlet.http.HttpServletRequest request)
          Returns the original host informations requested by the client or the proxies in the Host HTTP request headers.
static String[] getRequestHosts(javax.servlet.http.HttpServletRequest request, boolean checkRenderHost)
          Returns HTTP/1.1 compatible 'Host' header value.
static String getRequestPath(javax.servlet.http.HttpServletRequest request)
           
static String getRequestPath(javax.servlet.http.HttpServletRequest request, String characterEncoding)
           
static String getRequestServerName(javax.servlet.http.HttpServletRequest request)
          Returns the original host's server name requested by the client.
static int getRequestServerPort(javax.servlet.http.HttpServletRequest request)
          Returns the original host' port number requested by the client.
static String getRequestURI(javax.servlet.http.HttpServletRequest request, boolean excludeMatrixParameters)
           
static Map<String,String[]> parseQueryString(javax.servlet.http.HttpServletRequest request)
           
static String removeAllMatrixParams(String uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getHstRequest

public static HstRequest getHstRequest(javax.servlet.http.HttpServletRequest servletRequest)
Returns HstRequest object found in the servletRequest.

Parameters:
servletRequest -
Returns:

getHstResponse

public static HstResponse getHstResponse(javax.servlet.http.HttpServletRequest servletRequest,
                                         javax.servlet.http.HttpServletResponse servletResponse)
Returns HstResponse object found in the servletRequest or servletResponse.

Parameters:
servletRequest -
servletResponse -
Returns:

getHstRequestContext

public static HstRequestContext getHstRequestContext(javax.servlet.http.HttpServletRequest servletRequest)
Returns HstRequestContext object found in the servletRequest.

Parameters:
servletRequest -
Returns:

getRequestURI

public static String getRequestURI(javax.servlet.http.HttpServletRequest request,
                                   boolean excludeMatrixParameters)
Parameters:
request -
excludeMatrixParameters -
Returns:

getRequestPath

public static String getRequestPath(javax.servlet.http.HttpServletRequest request)
Parameters:
request -
Returns:
the decoded getRequestURI after the context path but before the matrix parameters or the query string in the request URL

getRequestPath

public static String getRequestPath(javax.servlet.http.HttpServletRequest request,
                                    String characterEncoding)
Parameters:
request -
characterEncoding -
Returns:
the decoded getRequestURI after the context path but before the matrix parameters or the query string in the request URL

getPathInfo

public static String getPathInfo(ResolvedMount mount,
                                 javax.servlet.http.HttpServletRequest request)
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information that comes after the context path and after the (resolved) mountpath but before the query string in the request URL This method extracts and decodes the path information from the request URI returned from HttpServletRequest#getRequestURI().

Parameters:
mount -
request -
Returns:
the decoded getRequestURI after the context path and after the (resolved) sitemount but before the query string in the request URL

getPathInfo

public static String getPathInfo(ResolvedMount mount,
                                 javax.servlet.http.HttpServletRequest request,
                                 String characterEncoding)

Returns any extra path information associated with the URL the client sent when it made this request. The extra path information that comes after the context path and after the (resolved) mountpath but before the query string in the request URL This method extracts and decodes the path information by the specified character encoding parameter from the request URI.

Parameters:
mount -
request -
characterEncoding -
Returns:
the decoded getRequestURI after the context path and after the ResolvedMount but before the query string in the request URL

getRequestHosts

public static String[] getRequestHosts(javax.servlet.http.HttpServletRequest request,
                                       boolean checkRenderHost)
Returns HTTP/1.1 compatible 'Host' header value.

Parameters:
request -
checkRenderHost -
Returns:

getRenderingHost

public static String getRenderingHost(javax.servlet.http.HttpServletRequest request)
Returns the rendering host of the current request, i.e. the host at which the request output is rendered. The rendering host can be set as a request parameter, or be present in the HTTP session. The request paramater value has precedence over the value in the HTTP session.

Parameters:
request - the servlet request
Returns:
the rendering host for the current request

getRequestHosts

public static String[] getRequestHosts(javax.servlet.http.HttpServletRequest request)
Returns the original host informations requested by the client or the proxies in the Host HTTP request headers.

Parameters:
request -
Returns:

getFarthestRequestHost

public static String getFarthestRequestHost(javax.servlet.http.HttpServletRequest request)
Returns the original host information requested by the client.

Parameters:
request -
Returns:

getFarthestRequestHost

public static String getFarthestRequestHost(javax.servlet.http.HttpServletRequest request,
                                            boolean checkRenderHost)
Returns the original host information requested by the client and do check optional injected render host information only when checkRenderHost is true

Parameters:
request -
checkRenderHost - when true the optional render host is used when present.
Returns:
the farthest request host or option render host when checkRenderHost is true

getRequestServerName

public static String getRequestServerName(javax.servlet.http.HttpServletRequest request)
Returns the original host's server name requested by the client.

Parameters:
request -
Returns:

getRequestServerPort

public static int getRequestServerPort(javax.servlet.http.HttpServletRequest request)
Returns the original host' port number requested by the client.

Parameters:
request -
Returns:

getRemoteAddrs

public static String[] getRemoteAddrs(javax.servlet.http.HttpServletRequest request)
Returns the remote host addresses related to this request. If there's any proxy server between the client and the server, then the proxy addresses are contained in the returned array. The lowest indexed element is the farthest downstream client and each successive proxy addresses are the next elements.

Parameters:
request -
Returns:

getFarthestRemoteAddr

public static String getFarthestRemoteAddr(javax.servlet.http.HttpServletRequest request)
Returns the remote client address.

Parameters:
request -
Returns:

parseQueryString

public static Map<String,String[]> parseQueryString(javax.servlet.http.HttpServletRequest request)

removeAllMatrixParams

public static String removeAllMatrixParams(String uri)


Copyright © 2008-2012 Hippo. All Rights Reserved.