Before OS/400 Release V4R3, CGI programs could only be run as
non-persistent.
A non-persistent CGI program is reloaded at every browser request.
Because of this, there is only one way a non-persistent CGI program
can know the values its variables had when it provided
an html response to a client browser.
This is done by saving variable values in fields of the
output html (usually "hidden" fields in an html form),
so that they are sent back to the program
with the next browser request.
Starting with OS/400 Release V4R3, CGI programs can be run as
persistent.
Persistent CGI is an extension to the CGI interface that allows a CGI
program to remain active across multiple browser requests and
maintain a session with that browser client.
This allows
the program state to be maintained
files to be left open
long running database transactions
to be committed or rolled back on end-user input.
The AS/400 CGI program must be created using a
named activation group
which allows the program to remain active
after returning to the server.
The CGI program notifies the server it wants to remain
persistent using the
"Accept-HTSession"
CGI header as the first header it returns in the output html.
This header defines the session ID associated with this instance of the
CGI program, is taken off from the http server, and is not
returned to the browser.
Subsequent URL requests to this program must contain
the session ID as the first parameter
after the program name.
The server uses this ID to route the request to that specific
instance of the CGI program.
The CGI program should
regenerate this session ID
for each request.
Though not mandatory, it is strongly recommended
that you use the Secure Socket Layer (SSL) for
persistent and secure business transaction processing.
There are three HTTP directives for persistent CGI jobs.
MaxPersistentCGI - Maximum number of persistent CGI jobs
Use this directive to set the
maximum number of persistent CGI jobs
that you want to have active at one time.
You can enter a number from 1 through 9999.
The default is 40.
This header must be preceded by an
Accept-HTSession header;
if not, it is ignored.
If you omit this header, the default time-out value for the
server is used.
Also a CGI persistent program,
after returning the ouput html to the browser
should return to the server.
This is different from a traditional non CGI program,
where the program sits after an EXFMT instruction.
do not set on the LR indicator,
when you want the program to remain active
for further requests
set on the LR indicator
when you want the program be no longer active.
In this case, make sure the browser
receives some html response, otherwise the
end user will wait until a script-timeout is issued
from the http server.
When receiving control from the http server,
the persistent CGI program should test some variable
of its own to establish the state it was left in.