wt.httpgw
Class HTTPServletRequest

java.lang.Object
  extended bywt.httpgw.HTTPRequest
      extended bywt.httpgw.HTTPServletRequest
All Implemented Interfaces:
CGIConstants, Serializable

public class HTTPServletRequest
extends HTTPRequest

See Also:
Serialized Form

Field Summary
private  Properties cgiData
           
private static boolean DEBUG
           
private  Properties formData
           
private  Hashtable formDataMultivalue
           
private static boolean getRemoteHost
           
private static boolean pathInfoNeedsDecoding
           
private  String queryString
           
private  javax.servlet.http.HttpServletRequest servletRequest
           
private static boolean setServletSession
           
private static Vector setServletSessionFilters
           
 
Fields inherited from class wt.httpgw.HTTPRequest
bizData, inputStream, response, serialVersionUID
 
Fields inherited from interface wt.httpgw.CGIConstants
CGI_ACCEPT, CGI_ACCEPT_CHARSET, CGI_ACCEPT_LANGUAGE, CGI_AUTH_TYPE, CGI_AUTHORIZATION, CGI_CONNECTION, CGI_CONTENT_LENGTH, CGI_CONTENT_TYPE, CGI_CONTEXT_PATH, CGI_DELETE_METHOD, CGI_GATEWAY_INTERFACE, CGI_GET_METHOD, CGI_HEAD_METHOD, CGI_HOST, CGI_IF_MODIFIED_SINCE, CGI_MULTIPART_BOUNDARY, CGI_PATH_INFO, CGI_PATH_TRANSLATED, CGI_POST_METHOD, CGI_PRAGMA, CGI_PROPERTY_PREFIX, CGI_PROTOCOL, CGI_PUT_METHOD, CGI_QUERY_STRING, CGI_REFERER, CGI_REMOTE_ADDR, CGI_REMOTE_HOST, CGI_REMOTE_IDENT, CGI_REMOTE_USER, CGI_REQUEST_METHOD, CGI_SCHEME, CGI_SCRIPT_NAME, CGI_SERVER_NAME, CGI_SERVER_PORT, CGI_SERVER_PROTOCOL, CGI_SERVER_SOFTWARE, CGI_SERVLET_SESSION, CGI_TRACE_METHOD, CGI_UA_COLOR, CGI_UA_CPU, CGI_UA_OS, CGI_UA_PIXELS, CGI_URI, CGI_URL, CGI_USER_AGENT, versionID
 
Constructor Summary
HTTPServletRequest(javax.servlet.http.HttpServletRequest request)
          Constructor
 
Method Summary
 String getBaseURL()
          Determine the Base URL of this script.
 String getEncoding()
          Guess user agent's file encoding from request headers.
static String getEscapedPathInfo(javax.servlet.http.HttpServletRequest httpServletRequest)
          Get path info from servlet request, decoding it if indicated necessary by wt.httpgw.pathInfoNeedsDecoding and then escaping it for use as part of a URL again.
 Properties getFormData()
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
 Properties getFormData(String encoding)
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
 Hashtable getFormDataMultivalue()
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
 Hashtable getFormDataMultivalue(String encoding)
          Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data.
 String getFullURL()
          Determine the Full URL of this script.
 String getMultiPartBoundary(String contentType)
          Utility routine to parse out the multipart object-body boundary

Supported API: false
static String getPathInfo(javax.servlet.http.HttpServletRequest httpServletRequest)
          Get path info from servlet request, decoding it if indicated necessary by wt.httpgw.pathInfoNeedsDecoding.
 String getProperty(String key)
          Public getter method for access to CGI data.
 String getProperty(String key, String default_value)
          Public getter method for access to CGI data.
 Enumeration getPropertyKeys()
          Public getter method for access to CGI data keys.
 String getQueryString()
          Gets the URLs query string in decoded format.
 String getQueryString(String encoding)
          Gets the URLs query string in decoded format.
 boolean isGetRequest()
          Determine if the REQUEST_METHOD used to send the data from the browser was the GET method.
 boolean isPostRequest()
          Determine if the REQUEST_METHOD used to send the data from the browser was the POST method.
 boolean isUrlencodedContent()
          Determine if the CONTENT_TYPE used to send the data from the browser was urlencoded form data.
 void listProperties(PrintWriter out)
          Public lister method for debug access to CGI data.
static void loadCgiData(Properties cgi_data, javax.servlet.http.HttpServletRequest req)
          Gets the HTTP request header info from a HttpServletRequest object and loads it into a Properties object.
 PrintWriter newPrintWriter(OutputStream output_stream)
          Utility routine to construct a buffered PrintWriter from an OutputStream.
private static String parseMultiPartBoundary(String contentType)
           
 void printFormDataHTML(PrintWriter out)
          Print all of the form data using HTML.
 void printHTMLBottom(PrintWriter out)
          Generate some vanilla HTML that you usually want to include at the bottom of any HTML page you generate.
 void printHTMLHeader(PrintWriter out)
          Print a standard HTTP HTML header.
 void printHTMLTop(PrintWriter out, String title)
          Generate some vanilla HTML that you usually want to include at the top of any HTML page you generate.
 void printPropertiesHTML(PrintWriter out)
          Print all of the CGI properties and the associated values using HTML.
private  String readQueryString()
          Reads the query string from the incoming input stream.
 void setFormData(Properties p)
          Sets the FORM data from a saved session.
 void setProperty(String key, String value)
          Public setter method for CGI data.
 Properties splitQueryString()
          Splits the URLs query string into name value pairs based on the ampersand and equal character tokens.
 Hashtable splitQueryStringMultivalue()
          Splits the URLs query string into name value pairs based on the ampersand and equal character tokens.
 
Methods inherited from class wt.httpgw.HTTPRequest
splitQueryString, splitQueryString, splitQueryStringMultivalue, splitQueryStringMultivalue, urlDecode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

formData

private Properties formData

formDataMultivalue

private Hashtable formDataMultivalue

servletRequest

private javax.servlet.http.HttpServletRequest servletRequest

queryString

private String queryString

cgiData

private Properties cgiData

DEBUG

private static boolean DEBUG

getRemoteHost

private static boolean getRemoteHost

setServletSession

private static boolean setServletSession

pathInfoNeedsDecoding

private static boolean pathInfoNeedsDecoding

setServletSessionFilters

private static Vector setServletSessionFilters
Constructor Detail

HTTPServletRequest

public HTTPServletRequest(javax.servlet.http.HttpServletRequest request)
                   throws WTIOException
Constructor

Parameters:
request - HttpServletRequest from javax.servlet.http
Method Detail

getPathInfo

public static final String getPathInfo(javax.servlet.http.HttpServletRequest httpServletRequest)
Get path info from servlet request, decoding it if indicated necessary by wt.httpgw.pathInfoNeedsDecoding.


getEscapedPathInfo

public static final String getEscapedPathInfo(javax.servlet.http.HttpServletRequest httpServletRequest)
Get path info from servlet request, decoding it if indicated necessary by wt.httpgw.pathInfoNeedsDecoding and then escaping it for use as part of a URL again.


loadCgiData

public static void loadCgiData(Properties cgi_data,
                               javax.servlet.http.HttpServletRequest req)
Gets the HTTP request header info from a HttpServletRequest object and loads it into a Properties object.

Parameters:
cgi_data - Properties object to load
req - the request object to load from

readQueryString

private String readQueryString()
Reads the query string from the incoming input stream.

Returns:
String the query string.

getFormData

public Properties getFormData()
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string. All hex escaped characters are decoded, then the sequence of 8-bit values is converted to characters using the character encoding returned by getEncoding.

Supported API: false

Specified by:
getFormData in class HTTPRequest
Returns:
Properties the form data as name value pairs.

getFormData

public Properties getFormData(String encoding)
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string. All hex escaped characters are decoded, then the sequence of 8-bit values is converted to characters using the given character encoding.

Supported API: false

Specified by:
getFormData in class HTTPRequest
Returns:
Properties the form data as name value pairs.

getFormDataMultivalue

public Hashtable getFormDataMultivalue()
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string. All hex escaped characters are decoded, then the sequence of 8-bit values is converted to characters using the character encoding returned by getEncoding.

Supported API: false

Specified by:
getFormDataMultivalue in class HTTPRequest
Returns:
Properties the form data as name value pairs.

getFormDataMultivalue

public Hashtable getFormDataMultivalue(String encoding)
Retrieves the FORM data from the incoming input stream as x-www-form-urlencoded data. If the input stream is null, it will read FORM data from the header query string. All hex escaped characters are decoded, then the sequence of 8-bit values is converted to characters using the given character encoding. Multivalue fields are stored in a Vector which can be iterated for the individual values.

Supported API: false

Specified by:
getFormDataMultivalue in class HTTPRequest
Returns:
Properties the form data as name value pairs.

getQueryString

public String getQueryString()
Gets the URLs query string in decoded format. All hex escaped characters are decoded. The sequence of 8-bit values is then converted to characters using UTF8 encoding.

Supported API: false

Specified by:
getQueryString in class HTTPRequest
Returns:
String the decoded query string.

getQueryString

public String getQueryString(String encoding)
Gets the URLs query string in decoded format. All hex escaped characters are decoded. The sequence of 8-bit values is then converted to characters using the given character encoding.

Supported API: false

Specified by:
getQueryString in class HTTPRequest
Returns:
String the decoded query string.

splitQueryString

public Properties splitQueryString()
Splits the URLs query string into name value pairs based on the ampersand and equal character tokens. The returned properties are URL decoded and then converted to characters using UTF8 encoding.

Supported API: false

Specified by:
splitQueryString in class HTTPRequest
Returns:
Properties the query string info as name value pairs.

splitQueryStringMultivalue

public Hashtable splitQueryStringMultivalue()
Splits the URLs query string into name value pairs based on the ampersand and equal character tokens. The returned properties are URL decoded and then converted to characters using UTF8 encoding.

Supported API: false

Specified by:
splitQueryStringMultivalue in class HTTPRequest
Returns:
Properties the query string info as name value pairs.

isGetRequest

public boolean isGetRequest()
Determine if the REQUEST_METHOD used to send the data from the browser was the GET method.

Supported API: false

Specified by:
isGetRequest in class HTTPRequest
Returns:
true, if the REQUEST_METHOD was GET. false, otherwise.

isPostRequest

public boolean isPostRequest()
Determine if the REQUEST_METHOD used to send the data from the browser was the POST method.

Supported API: false

Specified by:
isPostRequest in class HTTPRequest
Returns:
true, if the REQUEST_METHOD was POST. false, otherwise.

isUrlencodedContent

public boolean isUrlencodedContent()
Determine if the CONTENT_TYPE used to send the data from the browser was urlencoded form data.

Supported API: false

Specified by:
isUrlencodedContent in class HTTPRequest
Returns:
true, if the CONTENT_TYPE was urlencoded form data. false, otherwise.

getBaseURL

public String getBaseURL()
Determine the Base URL of this script. (Does not include the QUERY_STRING (if any) or PATH_INFO (if any).

Supported API: false

Specified by:
getBaseURL in class HTTPRequest
Returns:
The Base URL of this script as a String.

getFullURL

public String getFullURL()
Determine the Full URL of this script. (Includes the QUERY_STRING (if any) or PATH_INFO (if any).

Supported API: false

Specified by:
getFullURL in class HTTPRequest
Returns:
The Full URL of this script as a String.

getProperty

public String getProperty(String key)
Public getter method for access to CGI data.

Supported API: false

Specified by:
getProperty in class HTTPRequest
Returns:
String the value

getPropertyKeys

public Enumeration getPropertyKeys()
Public getter method for access to CGI data keys.

Supported API: false

Specified by:
getPropertyKeys in class HTTPRequest
Returns:
Enumeration of the keys

listProperties

public void listProperties(PrintWriter out)
Public lister method for debug access to CGI data. Output is not formated. For formated output (html), see the printPropertiesHTML method below.

Supported API: false

Specified by:
listProperties in class HTTPRequest

getProperty

public String getProperty(String key,
                          String default_value)
Public getter method for access to CGI data. If not set, default value is returned.

Supported API: false

Specified by:
getProperty in class HTTPRequest
Returns:
String the value

setProperty

public void setProperty(String key,
                        String value)
Public setter method for CGI data.

Supported API: false

Specified by:
setProperty in class HTTPRequest

getEncoding

public String getEncoding()
Guess user agent's file encoding from request headers. If Accept-Charset is specified, use the first value and apply a mapping of IANA names to Java encoding names. Mapping can be controlled at runtime with properties of the form wt.httpgw.encoding.xxx=yyy where xxx is the lower case IANA encoding name and yyy is the Java encoding name. If no Accept-Charset header is present, use template encoding rules to guess.

Supported API: false

Specified by:
getEncoding in class HTTPRequest
Returns:
String the encoding name

printHTMLHeader

public void printHTMLHeader(PrintWriter out)
                     throws IOException
Print a standard HTTP HTML header.

Supported API: false

Specified by:
printHTMLHeader in class HTTPRequest
Parameters:
out - PrintWriter to receive output.
Returns:
A String containing the standard HTTP HTML header.
Throws:
IOException

printHTMLTop

public void printHTMLTop(PrintWriter out,
                         String title)
                  throws IOException
Generate some vanilla HTML that you usually want to include at the top of any HTML page you generate.

Supported API: false

Specified by:
printHTMLTop in class HTTPRequest
Parameters:
out - PrintWriter to receive output.
Returns:
A String containing the top portion of an HTML file.
Throws:
IOException

printHTMLBottom

public void printHTMLBottom(PrintWriter out)
                     throws IOException
Generate some vanilla HTML that you usually want to include at the bottom of any HTML page you generate.

Supported API: false

Specified by:
printHTMLBottom in class HTTPRequest
Parameters:
out - PrintWriter to receive output.
Returns:
A String containing the bottom portion of an HTML file.
Throws:
IOException

printPropertiesHTML

public void printPropertiesHTML(PrintWriter out)
                         throws IOException
Print all of the CGI properties and the associated values using HTML.

Supported API: false

Specified by:
printPropertiesHTML in class HTTPRequest
Parameters:
out - PrintWriter to receive output.
Throws:
IOException

printFormDataHTML

public void printFormDataHTML(PrintWriter out)
                       throws IOException
Print all of the form data using HTML.

Supported API: false

Specified by:
printFormDataHTML in class HTTPRequest
Parameters:
out - PrintWriter to receive output.
Throws:
IOException

newPrintWriter

public PrintWriter newPrintWriter(OutputStream output_stream)
Utility routine to construct a buffered PrintWriter from an OutputStream.

Supported API: false

Specified by:
newPrintWriter in class HTTPRequest
Parameters:
output_stream - OutputStream to be wrapped
Returns:
A buffered PrintWriter constructed around the given OutPutStream.

getMultiPartBoundary

public String getMultiPartBoundary(String contentType)
Utility routine to parse out the multipart object-body boundary

Supported API: false

Specified by:
getMultiPartBoundary in class HTTPRequest
Parameters:
contentType - String containing the content-type and boundary, separated by a semi-colon
Returns:
A String containing the object-body boundary, not to exceed 70 characters per RFC1341

parseMultiPartBoundary

private static String parseMultiPartBoundary(String contentType)

setFormData

public void setFormData(Properties p)
Sets the FORM data from a saved session.

Supported API: false

Specified by:
setFormData in class HTTPRequest