FAQ : Frequently Asked Questions
FAQ Table of contents
blue line
7. Q:  Can you summarize the steps I have to go through in writing my first CGI?
A:  Suppose the following:
  • your images (gif's, jpg's, etc.) will reside in an IFS directory named myobjlib
  • your source library is named mysrclib
  • your object library (the one to contain your dynamic HTML scripts, your CGI programs, and Mel Rothman's service program CGISRVPGM) is named myobjlib
  • your first CGI program is named MYCGI1
Proceed as follow:
  1. Set up your CGI source and object libraries
    by entering command
    CGIDEV2/SETCGILIB SRCLIB(mysrclib) PRDLIB(myobjlib) .
    For information on this command please see linkthis page.
    • Note 1- Command SETCGILIB - when run from a user profile with *CHANGE authority on the HTTP configuration file ( QUSRSYS/QATMHTTPC) - will show you a list of the configuration files for the existing HTTP instances. If you select with a "1" a given HTTP instance, the program will add - to the configuration file of that HTTP instance - the HTTP directives needed to run your CGI programs in library myobjlib.
  2. Obtain a sample external html source and a sample CGI RPG source by using command
    CGIDEV2/CRTCGISRC SRCMBR(mycgi1) SRCLIB(mysrclib) PRDLIB(myobjlib)
    You may compile the module, create the CGI program and run it. Afterwards you may change both the external HTML and the CGI program to fit your needs.
    • Note 1. To create the module use commnad CRTRPGMOD and do not forget to specify DBGVIEW(*SOURCE).
      I would also recomment that you change the default value of this parameter once for ever entering command
      CHGCMDDFT CMD(CRTRPGMOD) NEWDFT('dbgview(*source)') .
    • Note 2. To create the CGI program, use command CRTPGM as specified in the initial comments of the RPG source.
    • Note 3. To run your CGI, use the instructions specified in the initial comments of the RPG source.
      If you receive Error 500, this means that either your program was not found, or that it bumped out during execution. In this case, get prepared for debugging reading linkthis page.
    • Note 4. See linkthis page for more information on how to divide this script into record-formats or sections and on how to define output variables.
blue line