Skip to main content development
   toolset
 
  Easy400   |       iSeries home
Public-Source
 
Introduction
Tutorial
Examples
FAQ
Index
Download
 
 

 
1.6 - Preparing libraries for CGI


When the time comes to start designing a new CGI WEB application on iSeries, create one or two libraries.

Two libraries, if you want to keep program and files separate from their sources.

One library, if you do not mind to have all them together.

Never create your CGI programs in our library cgicbldev2. By doing that you would later on have problems in installing a refresh release of library cgicbldev2.

You should instead populate your source and production library (or your single library) with the items needed for CGI development and execution.

You do this by using command cgicbldev2/setcgilib.

This command will not only populate your libraries, but optionally add Traditional/Apache HTTP directives to an HTTP instance of your choice.

Use command cgicbldev2/setcgilib to set up your source and production libraries for CGI programs:
Set lib.s for CGI development (SETCGILIB)
CGI source library . . . . . . . __________ Name CGI production library . . . . . __________ Name, *SRCLIB


CGI source library: The name of the library which will contain the sources of the CGI programs. This command creates the following objects in this library:

  1. Binding directory TEMPLATE2 to be used in creating the CGI programs
  2. Command, panel group, and CL program COMPILE to be used to regenerate your modules and programs (you need to update this program any time you create a new CGI module or program)
  3. the following source files, if missing
    • QDDSSRC
    • QCBLLESRC
    • QCLSRC
    • QCMDSRC
    • QPNLSRC


CGI production library: The name of the library which will contain the CGI programs. If you specify *SRCLIB, the source library is also the production library.
This command creates the following objects in this library:
  • A duplicate of service program CGICBLDEV2
  • Source file HTMLSRC for your html skeleton output members
  • Command CGIDEBUG, with file CGIDEBUG and data area CGIDEBUG, to let you debug your html inputs and outputs.

HTTP directives: If you signed on on with a user profile with has *change authority over the HTTPP instance control files (QUSRSYS/QATMHINSTC, QUSRSYS/QATMHTTPC), you are given the opportunity to generate HTTP directives for your CGI library.
If you are on a V5R2 system, command SETCGILIB asks whether you want to generate Original or Apache HTTP instance directives. If you are on a V5R3 or subsequent release, the question is not asked, as you can have only Apache HTTP directives.
You are then be presented a list of HTTP instances to choose from. Once you make a choice, the selected HTTP instance is added some basic HTTP directives related to your CGI library and to the hmonymous IFS directory.
The following are examples of generated HTTP directives.
  • Original HTTP directives
    Map  /myprdlibh/*  /QSYS.LIB/MYPRDLIB.LIB/HTMLSRC.FILE/*
    Pass /QSYS.LIB/MYPRDLIB.LIB/HTMLSRC.FILE/*
    Pass /myprdlib/*
    Exec /myprdlibp/*  /QSYS.LIB/MYPRDLIB.LIB/*  %%EBCDIC%%
    where myprdlib is the library name you specify for the production library. These four directives work as follow:
    1-The Map directive allows you to specify the shortcut name /myprdlibh/ (instead of /QSYS.LIB/MYPRDLIB.LIB/HTMLSRC.FILE/) in your html scripts (thus saving keystrokes and related errors)
    2-The first Pass directive allows HTTP to access members (containing static pages) in your HTMLSRC file
    3-The second Pass directive allows HTTP to access files in a root directory named as your production library: you could use such a directory to maintain images and static pages as well
    4-The Exec directive allows CGIs in the production library to be executed. The %%EBCDIC%% parameter allows the correct execution of zhbGetInput procedure (high performance procedure to read the input string from the remote browser).
  • Apache HTTP directives
    AliasMatch /myprdlibh/(.*)\.htm /QSYS.LIB/MYPRDLIB.LIB/HTMLSRC.FILE/$1.mbr
    Alias /myprdlibh/ /QSYS.LIB/MYPRDLIB.LIB/HTMLSRC.FILE/
    Alias /myprdlib/ /myprdlib/
    ScriptAliasMatch /myprdlibp(.*).pgm /qsys.lib/myprdlib.lib/$1.pgm
    <Directory /QSYS.LIB/MYPRDLIB.LIB>
      AllowOverride None
      Options None
      order allow,deny
    &%nbsp; allow from all
    </Directory>
    <Directory /myprdlib>
      AllowOverride None
      Options None
      order allow,deny
      allow from all
    </Directory>
    where myprdlib is the library name you specify for the production library. These directives work as follow:
    1-The first directive defines a short path myprdlibh/*.htm through which one may invoke static pages in file MYPRDLIB/HTMLSRC using extension .htm
    2-The second directive defines the short path myprdlibh which maps to MYPRDLIB/HTMLSRC
    3-The third directives informs that IFS path "/myprdlib" can be used
    4-The fourth directive allows execution of CGI programs in library MYPRDLIB. They must be invoked through their pseudo-path myprdlibp
    5-The first Directory group allows object in library MYPRDLIB to be accessed (basically: static pages in MYPRDLIB/HTMLSRC and CGI programs in library MYPRDLIB)
    6-The second Directory group allows IFS files in directory /myprdlib to be retrieved.



    Contact