com.jdon.util
类 RequestUtil

java.lang.Object
  继承者 com.jdon.util.RequestUtil

public class RequestUtil
extends Object

RequestUtil utility class Good ol' copy-n-paste from http://www.javaworld.com/javaworld/jw-02-2002/ssl/utilityclass.txt which is referenced in the following article: http://www.javaworld.com/javaworld/jw-02-2002/jw-0215-ssl.html


构造方法摘要
RequestUtil()
           
 
方法摘要
static StringBuilder createQueryStringFromMap(Map m, String ampersand)
          Builds a query string from a given map of parameters
static void deleteCookie(javax.servlet.http.HttpServletResponse response, javax.servlet.http.Cookie cookie, String path)
          Convenience method for deleting a cookie by name
static String encodeURL(String url)
           
static String encodeURL(String url, String enc)
          Use the new URLEncoder.encode() method from Java 1.4 if available, else use the old deprecated version.
static String getAppURL(javax.servlet.http.HttpServletRequest request)
          Convenience method to get the application's URL based on request variables.
static String[] getAuthCookie(javax.servlet.http.HttpServletRequest request)
           
static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest request, String name)
          Convenience method to get a cookie by name
static String getRequestParameters(javax.servlet.http.HttpServletRequest aRequest)
          Creates query String from request body parameters
static void reclaimRequestAttributes(javax.servlet.http.HttpServletRequest aRequest)
          Returns request attributes from session to request
static void saveAuthCookie(javax.servlet.http.HttpServletResponse response, String username, String password)
           
static void setCookie(javax.servlet.http.HttpServletResponse response, String name, String value, String path)
          Convenience method to set a cookie
static void stowRequestAttributes(javax.servlet.http.HttpServletRequest aRequest)
          Stores request attributes in session
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

RequestUtil

public RequestUtil()
方法详细信息

getRequestParameters

public static String getRequestParameters(javax.servlet.http.HttpServletRequest aRequest)
Creates query String from request body parameters


createQueryStringFromMap

public static StringBuilder createQueryStringFromMap(Map m,
                                                     String ampersand)
Builds a query string from a given map of parameters

参数:
m - A map of parameters
ampersand - String to use for ampersands (e.g. "&" or "&" )
返回:
query string (with no leading "?")

stowRequestAttributes

public static void stowRequestAttributes(javax.servlet.http.HttpServletRequest aRequest)
Stores request attributes in session

参数:
aRequest - the current request

reclaimRequestAttributes

public static void reclaimRequestAttributes(javax.servlet.http.HttpServletRequest aRequest)
Returns request attributes from session to request

参数:
aRequest - DOCUMENT ME!

saveAuthCookie

public static void saveAuthCookie(javax.servlet.http.HttpServletResponse response,
                                  String username,
                                  String password)

getAuthCookie

public static String[] getAuthCookie(javax.servlet.http.HttpServletRequest request)

setCookie

public static void setCookie(javax.servlet.http.HttpServletResponse response,
                             String name,
                             String value,
                             String path)
Convenience method to set a cookie

参数:
response -
name -
value -
path -

getCookie

public static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest request,
                                                  String name)
Convenience method to get a cookie by name

参数:
request - the current request
name - the name of the cookie to find
返回:
the cookie (if found), null if not found

deleteCookie

public static void deleteCookie(javax.servlet.http.HttpServletResponse response,
                                javax.servlet.http.Cookie cookie,
                                String path)
Convenience method for deleting a cookie by name

参数:
response - the current web response
cookie - the cookie to delete

getAppURL

public static String getAppURL(javax.servlet.http.HttpServletRequest request)
Convenience method to get the application's URL based on request variables.


encodeURL

public static String encodeURL(String url)

encodeURL

public static String encodeURL(String url,
                               String enc)
Use the new URLEncoder.encode() method from Java 1.4 if available, else use the old deprecated version. This method uses reflection to find the appropriate method; if the reflection operations throw exceptions, this will return the url encoded with the old URLEncoder.encode() method.

参数:
enc - The character encoding the urlencode is performed on.
返回:
String The encoded url.


Copyright © 2013. All Rights Reserved.