6.3.1 JSMResponse Class

The JSMReponse object is used to return a response to the JSM client program.

The JSMResponse object contains a status, message, byte array, list and field list object.

The Unicode status string value will be encoded to the native encoding of the client program.

The status value is copied into the #JSMSTS field of the LANSA Built-In Function API's.

The Unicode message string value will be encoded to the native encoding of the client program.

The message value is copied into the #JSMMSG field of the LANSA Built-In Function API's.

For Single-byte environments, Unicode characters encode to one byte for each character.

For Double-byte environments, Unicode characters encode to one byte for each character if no DBCS characters are present.

If DBCS characters are present, then Shift-Out and Shift-In characters will mark the change from one byte representing a character to two bytes representing a character.

If the byte size of status and message exceed their limits, an exception will be thrown during the send response stage.

The byte array variable content is copied to memory allocated within the JSM client program. No conversion is performed on the data.

Each new JSM command call, frees the memory allocated to store the previous command's byte array response.

The byte array memory also contains the HTTP response that will be passed onto the HTTP server when a JSM_CLOSE is performed.

A JSM_CLOSE call also frees the memory allocated by a byte array response.

It is recommended to always call JSM_CLOSE before ending a JSM client program.

The internal default settings are:

Status

OK

Message

zero length string object

ByteArray

zero length byte array object

List

null object

Fieldlist

null object

 

  

Two static final string variables called OK and ERROR are available for ease of use.

Example

 

  new JSMResponse ( "Ok message" ) ;

  new JSMResponse ( JSMResponse.OK, "Ok message" ) ;

  new JSMResponse ( JSMResponse.ERROR, "Error message" ) ;

  new JSMResponse ( exception ) ;