org.apache.catalina.util
Class RequestUtil

java.lang.Object
  |
  +--org.apache.catalina.util.RequestUtil

public final class RequestUtil
extends java.lang.Object

General purpose request parsing and encoding utility methods.

Version:
$Revision: 1.8 $ $Date: 2000/10/28 01:39:45 $
Author:
Craig R. McClanahan

Constructor Summary
RequestUtil()
           
 
Method Summary
static java.lang.String encodeCookie(javax.servlet.http.Cookie cookie)
          Encode a cookie as per RFC 2109.
static java.lang.String parseCharacterEncoding(java.lang.String contentType)
          Parse the character encoding from the specified content type header.
static javax.servlet.http.Cookie[] parseCookieHeader(java.lang.String header)
          Parse a cookie header into an array of cookies according to RFC 2109.
static void parseParameters(java.util.Map map, java.lang.String data)
          Append request parameters from the specified String to the specified Map.
static java.lang.String URLDecode(java.lang.String str)
          Decode and return the specified URL-encoded String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestUtil

public RequestUtil()
Method Detail

encodeCookie

public static java.lang.String encodeCookie(javax.servlet.http.Cookie cookie)
Encode a cookie as per RFC 2109. The resulting string can be used as the value for a Set-Cookie header.
Parameters:
cookie - The cookie to encode.
Returns:
A string following RFC 2109.

parseCharacterEncoding

public static java.lang.String parseCharacterEncoding(java.lang.String contentType)
Parse the character encoding from the specified content type header. If the content type is null, or there is no explicit character encoding, null is returned.
Parameters:
contentType - a content type header

parseCookieHeader

public static javax.servlet.http.Cookie[] parseCookieHeader(java.lang.String header)
Parse a cookie header into an array of cookies according to RFC 2109.
Parameters:
header - Value of an HTTP "Cookie" header

parseParameters

public static void parseParameters(java.util.Map map,
                                   java.lang.String data)
Append request parameters from the specified String to the specified Map. It is presumed that the specified Map is not accessed from any other thread, so no synchronization is performed.

IMPLEMENTATION NOTE: URL decoding is performed individually on the parsed name and value elements, rather than on the entire query string ahead of time, to properly deal with the case where the name or value includes an encoded "=" or "&" character that would otherwise be interpreted as a delimiter.

Parameters:
map - Map that accumulates the resulting parameters
data - Input string containing request parameters
Throws:
java.lang.IllegalArgumentException - if the data is malformed

URLDecode

public static java.lang.String URLDecode(java.lang.String str)
                                  throws java.lang.IllegalArgumentException
Decode and return the specified URL-encoded String.
Parameters:
str - The url-encoded string
Throws:
java.lang.IllegalArgumentException - if a '%' character is not followed by a valid 2-digit hexadecimal number


Copyright © 2000 Apache Software Foundation. All Rights Reserved.