Previous Topic Table Of Contents Parent Topic Next Topic |  | # The ADDRESS SWSSEND Host Command Environment Related Topics Web Server API Function Index ## Supported Environments The built-in `ADDRESS SWSSEND` Host Command Environment can be used in the following environments:
| Shadow/REXX-language WWW transaction procedures.
| Any other Shadow/REXX procedure
| Other REXX-language WWW transaction procedures
For environments where `ADDRESS SWSSEND` is unavailable, use the following:
| SWSSEND Built-in Function For Shadow/REXX and Other REXX interpreters
| The SWSSEND High-level language interface
## Use and Operation The `ADDRESS SWSSEND` host command environment is built-in to Shadow/REXX and can only be used by `/*WWW` transaction procedures. It provides an interface for creating an outbound Web transaction response and has the following advantages over the SWSSEND built-in function: The syntax for writing output data is simpler to use, easier to read, and simplifies making changes to an existing procedure. The execution path is shorter. 'Commands' passed to the `ADDRESS SWSSEND` environment are not actually commands at all, in the normal sense. Statements passed to the interface are data which is buffered for output to the Web client. Top ## ADDRESS SWSSEND Syntax The `ADDRESS SWSSEND` environment is referenced as for all REXX-language host command environments. You may code a stand-alone statement in the form:
        ADDRESS SWSSEND "data"
Or, you may pass multiple commands to the environment as:
        ADDRESS SWSSEND
        "data1"
        "data2"
        "data3"
## ADDRESS SWSSEND Operation Each 'command' passed to the `ADDRESS SWSSEND` environment is examined by the interface for special control values. If the command string does not contain a special control value, it is buffered for subsequent output to the Web client. The following rules are applied to 'command' data passed to the `ADDRESS SWSSEND` host environment. If the data line contains a single binary zero, it is ignored. If the data line contains a leading binary zero with one or more bytes following, the leading binary zero is stripped away. The remainder of the data line is buffered for output in binary form (the remaining data is not translated from EBCDIC to ASCII, and a CR/LF is not output following the data). If the data line consists entirely of the string 'FF'X||"PURGE", the data line is discarded and the current contents of the outbound transmission buffers are discarded. Any other data line passed to the interface, including a NULL string, are translated from EBCDIC to ASCII and a CR/LF sequence is appended to the end. Top ## ## Return Values After each 'command' line is passed to the `ADDRESS SWSSEND` environment, the built-in REXX variable, RC, is set to indicate the success or failure of the operation. A return code of 0 indicates that the operation completed successfully. Any other return code indicates a failure of the request, either due to the loss of the communications session or an internal error. ## Examples The following illustrates the use of`ADDRESS SWSSEND` in creating a text or HTML response:
       ADDRESS SWSSEND
       "HTTP/1.0 200 OK"
       "Content-type: text/html"
       ""
       "<HTML><BODY&GT;"
       "<H1>This is the Header</H1>"
       "<P>Additional text follows..."
       "</BODY></HTML&GT;"
The following calls generate binary format data:
       glength=0
       DO I = 1 TO GIFDATA.0
          glength = LENGTH(GIFDATA.I) + glength
       END
       ADDRESS SWSSEND
       "HTTP/1.0 200 OK"
       "Content-type: image/gif"
       "Content-length: "glength
       ""
       DO I = 1 to GIFDATA.0
          '00'X||GIFDATA.I
       END
The following calls purge previously buffered data and create a new transaction response:
       ADDRESS SWSSEND
       purgecmd = 'FF'X||"PURGE"
       purgecmd
       "HTTP/1.0 304 URL Moved"
       "Location: /new/url/location"
       ""
    Top