/* QUERY_STRING will contain the form data. */
/*--------------------------------------------------------------*/
queryString = getenv("QUERY_STRING");
if ( queryString ) {
/*----------------------------------------------------------*/
/* Write the QUERY_STRING data to stdout. */
/*----------------------------------------------------------*/
printf("<h4>Server input read from QUERY_STRING:</h4>");
queryStringLen = strlen(queryString);
if ( queryStringLen )
writeData(queryString, queryStringLen);
else
printf("<b>There is no data in QUERY_STRING.</b>");
} else
printf("<br>Error getting QUERY_STRING variable.");
} else
printf("<br><h2>ERROR: Invalid REQUEST_METHOD.</h2>");
/*------------------------------------------------------------------*/
/* Write break and paragraph html tag to stdout. */
/*------------------------------------------------------------------*/
printf("<br><p>\n");
/*------------------------------------------------------------------*/
/* Write the SERVER_SOFTWARE environment variable to stdout. */
/*------------------------------------------------------------------*/
serverSoftware = getenv("SERVER_SOFTWARE");
if ( serverSoftware )
printf("<h4>SERVER_SOFTWARE:</h4>%s\n", serverSoftware);
else
printf("<h4>Server Software is NULL</h4>");
/*-----------------------------------------------------------------*/
/* Write the closing tags on HTML document. */
/*-----------------------------------------------------------------*/
printf("</p>\n");
printf("</body>\n");
printf("</html>\n");
return;
}
Example of RPG language CGI program

To call the SAMPLE RPG program, add the following lines to an HTMLform:

<form method="POST" action="/CGI-BIN/SAMPLE.PGM">
<input name="YourInput" size=42,2>
<br>
Enter input for the RPG sample and click <input type="SUBMIT" value="ENTER">
<p>The output will be a screen with the text,
"YourInput=" followed by the text you typed above.
The contents of environment variable SERVER_SOFTWARE is also displayed.
</form>

The SAMPLE program shows how to write a CGI program in RPG language.

**************************************************************************
**** Sample ILE RPG program. ***
**** ***
****This sample code is provided by IBM for illustrative purposes only.***
****It has not been fully tested. It is provided as-is without any ***
****warranties of any kind, including but not limited to the implied ***
****warranties of merchantability and fitness for a particular purpose.***
Chapter6. Sample programs (in Java, C, and RPG) 99