com.q2learning.webtier.webhuddle
Class HttpRequest

java.lang.Object
  extended by com.q2learning.webtier.webhuddle.HttpRequest

public class HttpRequest
extends java.lang.Object

HttpRequest: utility class for requesting a web page via HTTP GET or POST methods.

11/20/2007 Charles Roth. First version.

Copyright (C) 2007 Q2learning LLC, www.q2learning.com. All rights reserved.


Constructor Summary
HttpRequest(java.lang.String url)
           
 
Method Summary
 void addParameter(java.lang.String name, java.lang.String value)
          Add a name/value parameter to the request.
 java.lang.String get()
          Request the page via the GET method.
 java.lang.String post()
          Request the page via the POST method.
 java.lang.String toString()
           
 java.lang.String UrlEncoder(java.lang.String url)
          Encode ("%hex-code" escape) characters that will be used in the query string of a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpRequest

public HttpRequest(java.lang.String url)
Parameters:
url - URL of page to request. Querystring parameters are usually added by addParameter().
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
useful String form of HttpRequest, as base URL and querystring.

addParameter

public void addParameter(java.lang.String name,
                         java.lang.String value)
Add a name/value parameter to the request. Does any necessary encoding for you. Call once for each parameter, as many times as desired.

Parameters:
name - Parameter name.
value - Parameter value.

UrlEncoder

public java.lang.String UrlEncoder(java.lang.String url)
Encode ("%hex-code" escape) characters that will be used in the query string of a URL.

Parameters:
url - the query string text.
Returns:
String appropriately escaped ("safe for URLs") text.

get

public java.lang.String get()
Request the page via the GET method.

Returns:
The entire HTML text of the page.

post

public java.lang.String post()
Request the page via the POST method.

Returns:
The entire HTML text of the page.