com.samskivert.servlet.util
Class RequestUtils

java.lang.Object
  extended by com.samskivert.servlet.util.RequestUtils

public class RequestUtils
extends Object

A repository of utility functions related to HTTP servlet stuff.


Constructor Summary
RequestUtils()
           
 
Method Summary
static String getLocation(javax.servlet.http.HttpServletRequest req)
          Reconstructs the current location (URL) from the request and servlet configuration (which is the only way to know which server we're on because that's not provided in the request) and returns it.
static String getLocationEncoded(javax.servlet.http.HttpServletRequest req)
          Reconstructs the current location (URL) from the request and servlet configuration (which is the only way to know which server we're on because that's not provided in the request) and returns it URL encoded so that it can be substituted into another URL.
static String getServletURL(javax.servlet.http.HttpServletRequest req, String path)
          Prepends the server, port and servlet context path to the supplied path, resulting in a fully-formed URL for requesting a servlet.
static String reconstructURL(javax.servlet.http.HttpServletRequest req)
          Reconstructs the request URL including query parameters.
static String rehostLocation(javax.servlet.http.HttpServletRequest req, String servername)
          Recreates the URL used to make the supplied request, replacing the server part of the URL with the supplied server name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestUtils

public RequestUtils()
Method Detail

getLocationEncoded

public static String getLocationEncoded(javax.servlet.http.HttpServletRequest req)
Reconstructs the current location (URL) from the request and servlet configuration (which is the only way to know which server we're on because that's not provided in the request) and returns it URL encoded so that it can be substituted into another URL.

Returns:
The URL encoded URL that represents our current location.

getLocation

public static String getLocation(javax.servlet.http.HttpServletRequest req)
Reconstructs the current location (URL) from the request and servlet configuration (which is the only way to know which server we're on because that's not provided in the request) and returns it.

Returns:
The URL that represents our current location.

rehostLocation

public static String rehostLocation(javax.servlet.http.HttpServletRequest req,
                                    String servername)
Recreates the URL used to make the supplied request, replacing the server part of the URL with the supplied server name.


getServletURL

public static String getServletURL(javax.servlet.http.HttpServletRequest req,
                                   String path)
Prepends the server, port and servlet context path to the supplied path, resulting in a fully-formed URL for requesting a servlet.


reconstructURL

public static String reconstructURL(javax.servlet.http.HttpServletRequest req)
Reconstructs the request URL including query parameters. Note: the output of this method is purely for logging purposes only, thus POST parameters are shown as if they were GET parameters and parameters are not URL encoded.



Copyright © 2000-2008 Michael Bayne. All Rights Reserved.