**** ***
**** This program is a simple RPG program that demonstrates the HTTP ***
**** server APIs for reading standard input, reading an environment ***
**** variable and writing standard output. This is done using the ***
**** IBM AS/400 HTTP Server APIs. ***
**** ***
**** The HTML at the end of this listing in CTDATA HTML is the text ***
**** that is modified by this program, written to standard output and ***
**** served to a client. ***
**** ***
**** 1-> Create HTML document as source physical file in library. ***
**** 2-> Set Source type of HTML document to HTML. ***
**** 3-> Create the *PGM object called SAMPLE(CRTRPGMOD and CRTPGM). ***
**** -Include the service program QTCP/QTMHCGI when doing the ***
**** CRTPGM in the BNDSRVPGM or BNDDIR parameter. ***
**** 4-> Check QTMHHTTP or *PUBLIC has access to document and QTMHHTP1 ***
**** or *PUBLIC has access to program(DSPOBJAUT and GRTOBJAUT). ***
**** 5-> Set up HTTP server configuration directives(WRKHTTPCFG) ***
**** 6-> Start the HTTP server(STRTCPSVR). ***
**** 7-> Run request from a browser. ***
**** ***
****------------------------ IMPORTANT --------------------------------***
**** The input for this program comes from CGI standard input or ***
**** the environment variable, QUERY_STRING. For an HTTP request ***
**** method of POST, the input is read from standard input and ***
**** for an HTTP request method of GET, the input is read from ***
**** QUERY_STRING. For method POST, this program will only read 1024 ***
**** characters. For method GET, the program will not read any ***
**** input data when it exceeds 1024 characters. The QtmhGetEnv ***
**** API will set the length of the environment variable response ***
**** to the actual length and no data is read into the receive ***
**** buffer. ***
****------------------------ IMPORTANT --------------------------------***
**** ***
**** Sample html form segment to run this sample CGI script: ***
**** ***
**** . ***
**** . ***
**** . ***
**** <form action="/cgi-bin/sample" method="POST"> ***
**** <input type="Text" maxsize=80 size=20 name="Sample"> ***
**** <input type="Submit name="SampleData" value="Submit CGI script"> ***
**** <br>Sample CGI program written in RPG.<br> ***
**** Type data and Click Submit to run a Sample program using RPG. ***
**** </form> ***
**** . ***
**** . ***
**** . ***
**** ***
**** HTTP Server configuration: ***
**** # Pass the html document in a library ***
**** Pass /sampledoc /qsys.lib/websamp.lib/htmlfile.file/sample.mbr ***
**** # Allow CGI program to run. ***
**** Map /cgi-bin/* /cgi-bin/*.pgm ***
**** Exec /cgi-bin/* /qsys.lib/websamp.lib/* ***
**** ***
**** This program is invoked by a URL from a browser in the form: ***
**** http://hostname/sampledoc ***
**** ***
**************************************************************************
**** ***
**** Function of this SAMPLE program: ***
**** Sample ILE RPG AS/400 program to demonstrate AS/400 HTTP server ***
**** CGI program. It reads data from standard input based on the ***
**** Content_Length environment variable. The QtmhGetEnv System API ***
**** is used to get the Content_Length and set the InDataLn variable ***
**** used by the QtmhRdStdIn API. The data to be returned to the ***
100 WebProgramming Guide V4R5