- Prepare your CGI libraries
Use command
cgidev2/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 . . . . . *SRCLIB 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:
- Command, panel group, and program COMPILE
to be used to regenerate your modules and programs
any time you have to change something
in your external data structure
- the following source files, if missing
- QDDSSRC
- QRPGLESRC
- QCLSRC
- QCMDSRC
- QPNLSRC
Note that source file QRPGLESRC will contain the following members
(to be copied into your CGI sources):
- hspecs (H specifications for module compilation)
- hspecsbnd (H specifications for binding,
so that you do not need any longer
to specify the bnddir keyword in your
crtpgm commands)
- prototypeb (prototypes for requesting services from Mel's
service program
- usec (data structure for return codes from API's)
- variables3 (variables common to CGI's)
- prolog3 (get the input string sent from the remote browser)
Note that it is your responsibility to maintain
CL program compile any time you develop a new
CGI module or program.
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:
- 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.
IFS directory:
An IFS directory with the same name of the CGI production library is created.
Three subdirectories are also created:
- /production_library/css for your .css files
- /production_library/html for your .html files
- /production_library/graphics for your graphical objects (icons, images, etc.)
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 homonymous 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/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/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
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. Example:
http://.../myprdlibp/program1.pgm
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 HTTP to access stream files in the IFS directory
/myprdlib .
- Create a sample CGI source
Use command
cgidev2/crtcgisrc
to create a sample ILE-RPG CGI source and the related
HTML in source file HTMLSRC.
The CGI is able to manage both the input (via ZhbGetInput and ZhbGetVar)
from the client and the output to the client.
You may easily create a module, create a CGI program,
and run it.
This will speed out your initial CGI developments.
Create sample CGI RPG source (CRTCGISRC)
ILE-RPG CGI source member . . . Name
CGI source library . . . . . . . Name
CGI production library . . . . . *SRCLIB Name, *SRCLIB
|
ILE-RPG CGI source member:
The name of source member to be created in
file QRPGLESRC in the source library.
CGI source library:
The name of the library which will contain the
sources of the CGI programs.
CGI production library:
The name of the library which will contain
the CGI programs.
|