com.ibm.wbi.protocol.http
Class HttpGenerator

com.ibm.wbi.Meg
  |
  +--com.ibm.wbi.Generator
        |
        +--com.ibm.wbi.protocol.http.HttpGenerator
Direct Known Subclasses:
CgiGenerator, FourStepHttpGenerator, MultipleCgiGenerator, MultipleFileGenerator, PutGenerator

public abstract class HttpGenerator
extends Generator

The abstract base class for Generators producing HTTP responses. This class simply contains an HttpResponse object and provides methods for manipulating that object. The object is not automatically used for producing an HTTP response, but is available for use by subclasses when they need to produce a response.

See Also:
HttpResponse

Field Summary
static java.lang.String COPYRIGHT
           
protected  HttpResponse http
          An object for manipulating the response that will ultimately be sent back to the browser.
 
Fields inherited from class com.ibm.wbi.Meg
EDITOR, GENERATOR, MONITOR, REQUEST_EDITOR, UNDEFINED
 
Constructor Summary
HttpGenerator()
          Construct a default HTTP Generator.
 
Method Summary
 void add(java.lang.String key, java.lang.String value)
          Add an arbitrary key/value pair of the HTTP Response object.
 void addCookie(java.lang.String name, java.lang.String value, java.util.Date expires, java.lang.String domain, java.lang.String path, boolean secure)
          Add a cookie to the HTTP Response object.
 java.lang.String getContentType()
          Get the ContentType property of the HTTP Response object.
 HttpResponse getHttpResponse()
          Access the HTTP Response object.
 java.lang.String getHttpResponseString()
          Convert the HTTP Response object into an HTTP response string.
 int getResponseCode()
          Get the ResponseCode property of the HTTP Response object.
 java.lang.String getResponseText()
          Get the ResponseText property of the HTTP Response object.
abstract  void handleRequest(RequestEvent e)
          The method used by Proxy to generate the document.
 boolean isCache()
          Access the Cache property of the HTTP Response object.
 java.lang.String produceHeader()
          Synonymous to getHTTPResponseString().
 void set(java.lang.String key, java.lang.String value)
          Set an arbitrary key/value pair of the HTTP Response object.
 void setCache(boolean c)
          Set the Cache property of the HTTP Response object.
 void setContentLength(long cl)
          Set the ContentLength property of the HTTP Response object.
 void setContentType(java.lang.String ct)
          Set the ContentType property of the HTTP Response object.
 void setResponseCode(int c)
          Set the ResponseCode property of the HTTP Response object.
 void setResponseText(java.lang.String t)
          Set the ResponseText property of the HTTP Response object.
 void setServer(java.lang.String s)
          Set the Server property of the HTTP Response object.
 void writeHeader(RequestEvent e)
          Write the HTTP Response to the given RequestEvent's output stream.
 
Methods inherited from class com.ibm.wbi.Generator
getType
 
Methods inherited from class com.ibm.wbi.Meg
forwardRequest, getCondition, getEnabled, getMegProperty, getMegProperty, getMegPropertyKeys, getName, getPlugin, getPriority, getSystemContext, initialize, initialize, isEnabled, isMegApplicable, loadMegResources, run, setCondition, setEnabled, setMegProperty, setName, setPriority, setSystemContext, setup, setup, setup, setup
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT

http

protected HttpResponse http
An object for manipulating the response that will ultimately be sent back to the browser. This object is manipulated by the various methods of this class. It is then available for use by subclasses which implement the handleRequest(RequestEvent) method. Keep one universal copy in case the derived Generator always has the same HTTP info
Constructor Detail

HttpGenerator

public HttpGenerator()
Construct a default HTTP Generator.
Method Detail

getHttpResponse

public HttpResponse getHttpResponse()
Access the HTTP Response object.
Returns:
The response.

getHttpResponseString

public java.lang.String getHttpResponseString()
Convert the HTTP Response object into an HTTP response string.
Returns:
The response.

setContentType

public void setContentType(java.lang.String ct)
Set the ContentType property of the HTTP Response object.
Parameters:
ct - The ContentType.
See Also:
HttpBase.setContentType(java.lang.String)

getContentType

public java.lang.String getContentType()
Get the ContentType property of the HTTP Response object.
Returns:
the ContentType.
See Also:
HttpBase.getContentType()

setContentLength

public void setContentLength(long cl)
Set the ContentLength property of the HTTP Response object.
Parameters:
cl - The ContentLength.
See Also:
HttpBase.setContentLength(long)

set

public void set(java.lang.String key,
                java.lang.String value)
Set an arbitrary key/value pair of the HTTP Response object.
Parameters:
key - The key.
value - The value.
See Also:
HttpBase.set(java.lang.String, java.lang.String)

add

public void add(java.lang.String key,
                java.lang.String value)
Add an arbitrary key/value pair of the HTTP Response object.
Parameters:
key - The key.
value - The value.
See Also:
HttpBase.add(java.lang.String, java.lang.String)

addCookie

public void addCookie(java.lang.String name,
                      java.lang.String value,
                      java.util.Date expires,
                      java.lang.String domain,
                      java.lang.String path,
                      boolean secure)
Add a cookie to the HTTP Response object.
Parameters:
name - The name of the cookie.
value - The value.
expires - The date it expires.
domain - The domain.
path - The path.
secure - Is secure?
See Also:
HttpResponse.addCookie(java.lang.String, java.lang.String, java.util.Date, java.lang.String, java.lang.String, boolean)

getResponseCode

public int getResponseCode()
Get the ResponseCode property of the HTTP Response object.
Returns:
The ResponseCode.
See Also:
HttpResponse.getResponseCode()

setResponseCode

public void setResponseCode(int c)
Set the ResponseCode property of the HTTP Response object.
Parameters:
c - The ResponseCode.
See Also:
HttpResponse.setResponseCode(int)

getResponseText

public java.lang.String getResponseText()
Get the ResponseText property of the HTTP Response object.
Returns:
The ResponseText.
See Also:
HttpResponse.getResponseText()

setResponseText

public void setResponseText(java.lang.String t)
Set the ResponseText property of the HTTP Response object.
Parameters:
t - The ResponseText.
See Also:
HttpResponse.setResponseText(java.lang.String)

produceHeader

public java.lang.String produceHeader()
Synonymous to getHTTPResponseString().
Returns:
The HTTP Response string.
See Also:
getHTTPResponseString

writeHeader

public void writeHeader(RequestEvent e)
Write the HTTP Response to the given RequestEvent's output stream.
Parameters:
e - Request event.

setServer

public void setServer(java.lang.String s)
Set the Server property of the HTTP Response object.
Parameters:
s - Server.
See Also:
HttpResponse.setServer(java.lang.String)

setCache

public void setCache(boolean c)
Set the Cache property of the HTTP Response object.
Parameters:
c - Cache property.
See Also:
HttpResponse.setCache(boolean)

isCache

public boolean isCache()
Access the Cache property of the HTTP Response object.
See Also:
HttpResponse.isCache()

handleRequest

public abstract void handleRequest(RequestEvent e)
                            throws RequestRejectedException,
                                   java.io.IOException
The method used by Proxy to generate the document. This method must be implemented by subclasses.
Overrides:
handleRequest in class Generator
Parameters:
e - The RequestEvent.
Throws:
RequestRejectedException - If rejecting request, this must be thrown before the first write() is made to the output stream.
java.io.Exception - can be thrown if an exception was generated by the Meg while processing the MegInput/OutputStreams.