4 - Tips for developing persistent CGI RPG programs
- 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.
- Have the program itself regenerating every time a new
session ID
(also called "handle")
to be inserted in two points of the output html:
In building a new session ID, you may use a random number
obtained through Mel's service program
random subprocedure.
- When creating a persistent CGI program,
be sure to specify a
named activation group
in the parameter ACTGRP.
As an example, the name of the activation group could be the
same for all CGIs in an application.
5 - Calling another program from a persistent one
Calling another program from inside a CGI persistent program may have unpredictable results.
The best practice is to perform this "call" through the external HTML.
Example: through some javascript function, or from abutton submitting a <form>.
In this way the HTTP server starts a new request which is then routed to a job different from the one currently running the persistent program.
In this way the persistent program maintains its status.
As soon as the called program returns to its caller, HTTP returns to the last web page where the call was activated.
As an example, see how the
Giovanni Perotti's demo (a persistent CGI program, listed in the next topic) performs a call to a non-persistent CGI program,
the one running the Boats Demo.
5 - Sample persistent CGI RPG programs
Mel Rothman's demo |
|
Giovanni Perotti's demo |
What day of the week?
It computes its Session ID ("Handle")
using the getSessionID subprocedure.
|
|
Sample persistent RPG CGI program
It computes its Session ID ("Handle")
just using the random subprocedure.
|