com.ibm.cics.server
Class HttpResponse

java.lang.Object
  extended bycom.ibm.cics.server.HttpResponse

public class HttpResponse
extends java.lang.Object

Usage:
This class provides the Java implementation of HTTP responses related to the following CICS API WEB server commands:

The writeHeader() method allows HTTP header information to be added to a response. This is equivalent to CICS API command WEB WRITE.

The setter methods allow instance variables to be set in the HttpResponse object. These variables relate to the following options on the CICS API command WEB SEND:

The sendDocument() method sends the specified Document object to the clients browser. This is equivalent to CICS API command WEB SEND DOCUMENT.

The sendFrom() method sends an application buffer to the clients browser. This is equivalent to CICS API command WEB SEND FROM.

The sendChunk() sends a chunk of a chunked response to the client. When all the chunks of the chunked response have been sent the sendLastChunk() method must be used to terminate the chunked response. This is equivalent to using CICS API commands WEB SEND FROM CHUNKYES and WEB SEND CHUNKEND to send a chunked response.

A equivalent method for CICS API command WEB RETRIEVE is not supplied. This command returns the DOCTOKEN of the document sent using an earlier WEB SEND command. The Document object sent by the sendDocument() method should still be available so a method equivalent to this command is not required.


Field Summary
static int NOTSET
           
 
Constructor Summary
HttpResponse()
          Usage:
Public default constructor.
 
Method Summary
 void sendChunk(byte[] from)
          Usage:
Send a chunk of the chunked response to the client.
 void sendChunk(java.lang.String from)
          Usage:
Send a chunk of the chunked response to the client.
 void sendDocument(Document doc)
          Usage:
Send a document to the client.
 void sendDocument(Document doc, short statusCode, java.lang.String statusText, java.lang.String clntCodePage)
          Usage:
Send a document to the client.
 void sendFrom(byte[] from)
          Usage:
Send an application buffer to the client.
 void sendFrom(java.lang.String from)
          Usage:
Send an application buffer to the client.
 void sendLastChunk()
          Usage:
Indicate that the chunked response is complete.
 void setActionEventual()
          Usage:
Sets WEB SEND command option ACTION to EVENTUAL.
 void setActionImmediate()
          Usage:
Sets WEB SEND command option ACTION to IMMEDIATE.
 void setClientCodePage(java.lang.String clntCodePage)
          Usage:
Sets WEB SEND command option CLNTCODEPAGE.
 void setClose()
          Usage:
Sets WEB SEND command option CLOSESTATUS to CLOSE.
 void setHostCodePage(java.lang.String hostCodePage)
          Usage:
Sets WEB SEND command option HOSTCODEPAGE.
 void setMediaType(java.lang.String mediaType)
          Usage:
Sets WEB SEND command option MEDIATYPE.
 void setNoClose()
          Usage:
Sets WEB SEND command option CLOSESTATUS to NOCLOSE.
 void setNoServerConvert()
          Usage:
Sets WEB SEND command option SERVERCONV to NOSRVCONVERT.
 void setServerConvert()
          Usage:
Sets WEB SEND command option SERVERCONV to SRVCONVERT.
 void setStatus(short statusCode, java.lang.String statusText)
          Usage:
Sets WEB SEND command option STATUSCODE and STATUSTEXT..
 void writeHeader(java.lang.String header, java.lang.String value)
          Usage:
Add HTTP header information to the response.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTSET

public static final int NOTSET
See Also:
Constant Field Values
Constructor Detail

HttpResponse

public HttpResponse()
Usage:
Public default constructor.

Throws:
None
Method Detail

writeHeader

public void writeHeader(java.lang.String header,
                        java.lang.String value)
                 throws InvalidRequestException
Usage:
Add HTTP header information to the response. This is equivalent to CICS API command WEB WRITE.

Parameters:
header - contains the name of the HTTP header
value - contains the value of the named header
Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred

setServerConvert

public void setServerConvert()
Usage:
Sets WEB SEND command option SERVERCONV to SRVCONVERT.

Returns:
None
Throws:
None

setNoServerConvert

public void setNoServerConvert()
Usage:
Sets WEB SEND command option SERVERCONV to NOSRVCONVERT. This method also clears CLNTCODEPAGE and HOSTCODEPAGE information set by methods setClientCodePage() and setHostCodePage().

Returns:
None
Throws:
None

setClientCodePage

public void setClientCodePage(java.lang.String clntCodePage)
Usage:
Sets WEB SEND command option CLNTCODEPAGE. This method also sets SERVERCONV to SRVCONVERT.

Parameters:
clntCodePage - contains the codepage into which the HTTP response body is to be converting when the WEB SEND command is issued
Returns:
None
Throws:
None

setHostCodePage

public void setHostCodePage(java.lang.String hostCodePage)
Usage:
Sets WEB SEND command option HOSTCODEPAGE. This method also sets SERVERCONV to SRVCONVERT. This option is ignored if method sendDocument() is used to send a document.

Parameters:
hostCodePage - contains the codepage that the data being sent by the WEB SEND command is encoded in
Returns:
None
Throws:
None

setMediaType

public void setMediaType(java.lang.String mediaType)
Usage:
Sets WEB SEND command option MEDIATYPE.

Parameters:
mediaType - contains mediatype information to be used by the WEB SEND command
Returns:
None
Throws:
None

setStatus

public void setStatus(short statusCode,
                      java.lang.String statusText)
Usage:
Sets WEB SEND command option STATUSCODE and STATUSTEXT..

Parameters:
statusCode - contains a HTTP status code
statusText - contains text describing the value of the status code
Returns:
None
Throws:
None

setClose

public void setClose()
Usage:
Sets WEB SEND command option CLOSESTATUS to CLOSE.

Returns:
None
Throws:
None

setNoClose

public void setNoClose()
Usage:
Sets WEB SEND command option CLOSESTATUS to NOCLOSE.

Returns:
None
Throws:
None

setActionEventual

public void setActionEventual()
Usage:
Sets WEB SEND command option ACTION to EVENTUAL.

Returns:
None
Throws:
None

setActionImmediate

public void setActionImmediate()
Usage:
Sets WEB SEND command option ACTION to IMMEDIATE.

Returns:
None
Throws:
None

sendDocument

public void sendDocument(Document doc,
                         short statusCode,
                         java.lang.String statusText,
                         java.lang.String clntCodePage)
                  throws InvalidRequestException,
                         RecordNotFoundException,
                         LengthErrorException,
                         IOErrorException
Usage:
Send a document to the client. This is equivalent to CICS API command WEB SEND DOCUMENT. The required command options should have been saved in the HttpResponse object before this method is used to send the response to the client.

Parameters:
doc - is the Document object to be sent to the client
statusCode - contains a HTTP status code
statusText - contains text describing the value of the status code
clntCodePage - contains the name of the ASCII codepage in which the data is to be delivered to the browser
Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred
RecordNotFoundException - a NOTFND condition occurred
LengthErrorException - a LENGERR condition occurred
IOErrorException - a IOERR condition occurred

sendDocument

public void sendDocument(Document doc)
                  throws InvalidRequestException,
                         RecordNotFoundException,
                         LengthErrorException,
                         IOErrorException
Usage:
Send a document to the client. This is equivalent to CICS API command WEB SEND DOCUMENT. The required command options should have been saved in the HttpResponse object before this method is used to send the response to the client.

Parameters:
doc - is the Document object to be sent to the client
Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred
RecordNotFoundException - a NOTFND condition occurred
LengthErrorException - a LENGERR condition occurred
IOErrorException - a IOERR condition occurred

sendFrom

public void sendFrom(java.lang.String from)
              throws InvalidRequestException,
                     RecordNotFoundException,
                     LengthErrorException,
                     IOErrorException
Usage:
Send an application buffer to the client. This is equivalent to CICS API command WEB SEND FROM. The required command options should have been saved in the HttpResponse object before this method is used to send the response to the client.

Parameters:
from - is the data to be sent to the client
Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred
RecordNotFoundException - a NOTFND condition occurred
LengthErrorException - a LENGERR condition occurred
IOErrorException - a IOERR condition occurred

sendFrom

public void sendFrom(byte[] from)
              throws InvalidRequestException,
                     RecordNotFoundException,
                     LengthErrorException,
                     IOErrorException
Usage:
Send an application buffer to the client. This is equivalent to CICS API command WEB SEND FROM. The required command options should have been saved in the HttpResponse object before this method is used to send the response to the client.

Parameters:
from - is the data to be sent to the client
Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred
RecordNotFoundException - a NOTFND condition occurred
LengthErrorException - a LENGERR condition occurred
IOErrorException - a IOERR condition occurred

sendChunk

public void sendChunk(java.lang.String from)
               throws InvalidRequestException,
                      RecordNotFoundException,
                      LengthErrorException,
                      IOErrorException
Usage:
Send a chunk of the chunked response to the client. This is equivalent to CICS API command WEB SEND FROM CHUNKYES. The required command options should have been saved in the HttpResponse object before this method is used to send the response to the client.

Parameters:
from - is the data that forms a subsequent chunk of the chunked response being sent to the client
Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred
RecordNotFoundException - a NOTFND condition occurred
LengthErrorException - a LENGERR condition occurred
IOErrorException - a IOERR condition occurred

sendChunk

public void sendChunk(byte[] from)
               throws InvalidRequestException,
                      RecordNotFoundException,
                      LengthErrorException,
                      IOErrorException
Usage:
Send a chunk of the chunked response to the client. This is equivalent to CICS API command WEB SEND FROM CHUNKYES. The required command options should have been saved in the HttpResponse object before this method is used to send the response to the client.

Parameters:
from - is the data that forms a subsequent chunk of the chunked response being sent to the client
Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred
RecordNotFoundException - a NOTFND condition occurred
LengthErrorException - a LENGERR condition occurred
IOErrorException - a IOERR condition occurred

sendLastChunk

public void sendLastChunk()
                   throws InvalidRequestException,
                          RecordNotFoundException,
                          LengthErrorException,
                          IOErrorException
Usage:
Indicate that the chunked response is complete. This is equivalent to CICS API command WEB SEND CHUNKEND.

Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred
RecordNotFoundException - a NOTFND condition occurred
LengthErrorException - a LENGERR condition occurred
IOErrorException - a IOERR condition occurred