Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class javax.servlet.http.HttpUtils

java.lang.Object
    |
    +----javax.servlet.http.HttpUtils

public class HttpUtils
extends Object
A collection of static utility methods useful to HTTP servlets.


Method Summary
static StringBuffer  getRequestURL(HttpServletRequest req)
Reconstructs the URL used by the client used to make the request.
static Hashtable  parsePostData(int len, ServletInputStream in)
Parses FORM data that is posted to the server using the HTTP POST method and the application/x-www-form-urlencoded mime type.
static Hashtable  parseQueryString(String s)
Parses a query string and builds a hashtable of key-value pairs, where the values are arrays of strings.
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseQueryString

public static Hashtable parseQueryString(String s)
Parses a query string and builds a hashtable of key-value pairs, where the values are arrays of strings. The query string should have the form of a string packaged by the GET or POST method. (For example, it should have its key-value pairs delimited by ampersands (&) and its keys separated from its values by equal signs (=).)

A key can appear one or more times in the query string. Each time a key appears, its corresponding value is inserted into its string array in the hash table. (So keys that appear once in the query string have, in the hash table, a string array of length one as their value, keys that appear twice have a string array of length two, etc.)

When the keys and values are moved into the hashtable, any plus signs (+) are returned to spaces and characters sent in hexadecimal notation (%xx) are converted back to characters.

Parameters:
s - query string to be parsed
Returns:
a hashtable built from the parsed key-value pairs; the .hashtable's values are arrays of strings
Throws:
IllegalArgumentException - if the query string is invalid.

parsePostData

public static Hashtable parsePostData(int len,
                                      ServletInputStream in)
Parses FORM data that is posted to the server using the HTTP POST method and the application/x-www-form-urlencoded mime type.
Parameters:
len - the length of the data in the input stream.
in - the input stream
Returns:
a hashtable of the parsed key, value pairs. Keys with multiple values have their values stored as an array of strings
Throws:
IllegalArgumentException - if the POST data is invalid.

getRequestURL

public static StringBuffer getRequestURL(HttpServletRequest req)
Reconstructs the URL used by the client used to make the request. This accounts for differences such as addressing scheme (http, https) and default ports, but does not attempt to include query parameters. Since it returns a StringBuffer, not a String, the URL can be modified efficiently (for example, by appending query parameters).

This method is useful for creating redirect messages and for reporting errors.


Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.