javax.servlet.http
Class HttpUtils
java.lang.Object
javax.servlet.http.HttpUtils
public class HttpUtils
extends java.lang.Object
A set of utility methods for http server writers.
HttpUtils() - Creates a HttpUtils object, cool!
|
static StringBuffer | getRequestURL(HttpServletRequest request) - Determines which URL the client used when issuing his request.
|
static Hashtable | parsePostData(int contentLength, ServletInputStream in) - Reads the data provided by the client using the POST method,
passes these on to HttpUtils.parseQueryString for further treatment,
and returns the resulting Hashtable.
|
static Hashtable | parseQueryString(String queryString) - Turns a http QUERY_STRING that conforms to
rfc1945("Hypertext Transfer Protocol -- HTTP/1.0") or
rfc2068 ("Hypertext Transfer Protocol -- HTTP/1.1") into a Hashtable
with key = key and as values arrays of String.
|
HttpUtils
public HttpUtils()
Creates a HttpUtils object, cool!
getRequestURL
public static StringBuffer getRequestURL(HttpServletRequest request)
Determines which URL the client used when issuing his request.
Does not return the querystring (the ?name=value part)
parsePostData
public static Hashtable parsePostData(int contentLength,
ServletInputStream in)
throws IllegalArgumentException
Reads the data provided by the client using the POST method,
passes these on to HttpUtils.parseQueryString for further treatment,
and returns the resulting Hashtable.
bonus:
When contentLength < 0 it keeps on reading data until EOF
throws an IllegalArgumentException when contentLength != amount of data in the inputstream
- a Hashtable with String keys, and array of String values.
parseQueryString
public static Hashtable parseQueryString(String queryString)
throws IllegalArgumentException
Turns a http QUERY_STRING that conforms to
rfc1945("Hypertext Transfer Protocol -- HTTP/1.0") or
rfc2068 ("Hypertext Transfer Protocol -- HTTP/1.1") into a Hashtable
with key = key and as values arrays of String.
Implementation note: when a key or value is missing it will be
represented as a zero length string.
Results:
?a=b : key = "a", value = "b"
?a : key = "a", value = ""
?=b : key = "", value = "b"
queryString
- The queryString to process
- a Hashtable with String keys, and array of String values.