HttpUtils

Java Servlet Programming, 2nd Edition > B. HTTP Servlet API Quick Reference > HttpUtils

 
< BACKCONTINUE >
HttpUtils

Synopsis

Class Name: javax.servlet.http.HttpUtils

Superclass: java.lang.Object

Immediate Subclasses: None

Interfaces Implemented: None

Availability: Servlet API 1.0 and later

Description

A container object for a handful of potentially useful HTTP-oriented methods.

Class Summary

public class HttpUtils {   // Constructors   public HttpUtils();   // Class methods   public static StringBuffer getRequestURL(HttpServletRequest req);   public static Hashtable parsePostData(int len, ServletInputStream in);   public static Hashtable parseQueryString(String s); }

Constructors

HttpUtils()

public HttpUtils()
Description

The default constructor does nothing.

Class Methods

getRequestURL()

public static StringBuffer getRequestURL(HttpServletRequest req)
Description

Reconstitutes the request URL based on information available in the HttpServletRequest object. Returns a StringBuffer that includes the scheme, server name, server port, and extra path information, but not the query string. The reconstituted URL should look almost identical to the URL used by the client. This method can be used for error reporting, redirecting, and URL creation. For applications that need to uniquely identify particular servlets, the getRequestURI( ) method of HttpServletRequest is generally a better choice.

parsePostData()

public static Hashtable parsePostData(int len, ServletInputStream in)
Description

Parses len characters of parameter data from a ServletInputStream (usually sent as part of a POST operation). Throws an IllegalArgumentException if the parameter data is invalid. Most servlets use getParameterNames( ), getParameter( ), and getParameterValues( ) instead of this method.

parseQueryString()

public static Hashtable parseQueryString(String s)
Description

Returns a Hashtable where the hashtable keys are the parameter names taken from the query string and each hashtable value is a String array that contains the parameter's decoded value(s). Throws an IllegalArgumentException if the query string is invalid. Most servlets use getParameterNames( ), getParameter( ), and getParameterValues( ) instead. It is not safe to use both.


Last updated on 3/20/2003
Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

< BACKCONTINUE >


Java servlet programming
Java Servlet Programming (Java Series)
ISBN: 0596000405
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net