MPE Proglets
Here is yet another approach to generate dynamic web pages using plain
MPE programs. I've coined the term MPE Proglet with the commonly
known Java Applet or Java Servlet terms in mind. As you probably know,
a Java Applet extends the functionality of a Java capable web browser
with "user supplied" code, and a Java Servlet extends the functionality
of a Java capable web server with "user supplied" code. Similar
to Java Servlets, MPE Proglets are meant to extend the server
side, however using native MPE program code. Unlike CGI programming, the
MPE Proglet approach uses an MPE friendly way of passing parameters and
results, though.
Concept
The basic idea of MPE Proglets is to use a small Java Servlet to interface
a fairly straightforward MPE program to the web. The servlet is responsible
for dealing with the incoming http request, whereas the MPE program implements
native access to files or databases and creates the resulting HTML response.
The servlet is fairly generic, so that the programmer can focus on the
MPE code in most cases.
Unlike CGI, the Java Servlet and MPE program are not short-lived, but
designed to handle multiple web requests over their lifetime. This helps
to reduce the overhead caused by process creation/deletion or database
opening/closing that is typical for CGI solutions.
An incoming browser request wakes up the Java servlet, which takes care
of parsing parameters like QueryString, PathInfo, or HTML form fields and
values. The servlet invokes (or awakes) the MPE program over a JavaTelnet
session. The MPE program first performs a fairly simple prompt-and-response
dialog with the servlet to retrieve the interesting http parameters. It
then processes the input, using access to flat files, KSAM files, databases
or whatever (native) MPE resources, and outputs a dynamic web page by displaying
the results with appropriate HTML tags. The servlet passes the response
back to the web client and then both, Java servlet and MPE program, wait
until the next request from a browser comes in.
The prompt-and-response dialog between MPE program and Java servlet
is fairly simple. It begins with the MPE program prompting for "HTTP>
",
which the servlet answers with either GET or POST, depending
on the type of http request. The MPE program can then prompt for additional
info, like "PATHINFO> " or "QUERYSTRING> " or "SOME-HTMLFORM-FIELDNAME>
".
The servlet answers these prompts with respective info from the http request.
The MPE program ends the parameter dialog by introducing the resulting
HTML page with "<html>" and ends the web page output phase
with an "</html>" tag. At this point, the MPE program starts
waiting for a new request by emitting the "HTTP> " prompt again.
Pro's
-
Java Servlet handles http request and parameter parsing conveniently
-
handles GET and POST, parses args like "name=lars+appel&out=%24null"
-
MPE program can use efficient native code and native access to files and
databases
-
helps with integration with "legacy" libraries and applications
-
Java servlet is fairly generic, programmer can focus on the MPE code in
most cases
-
different servlet instances can be used to drive different MPE programs
-
Less process creation/deletion and file/database opening/closing overhead
than CGI
-
with CGI, each web request creates a process and opens databases
-
with Proglet approach, most requests only awake a running program
-
MPE program runs in regular session context; quite different from CGI programming
-
no contention issues with resources like file equations, CI variables,
or JCWs
-
MPE program uses regular terminal I/O; quite different from CGI programming
-
no explicit network, socket or pipe programming; use language specific
I/O verbs
-
Servlet engine can maintain a pool of multiple servlets and associated
JavaTelnet sessions
-
allows for concurrent request handling and better multiprocessor scaling
Con's
-
Session pool with MPE programs counts against MPE user limit
-
however, the session pool is typically smaller than the actual number of
web users
-
JavaTelnet sessions cost more processes than simple children
-
pools of telnet sessions needs more processes than a pool of child processes
-
however, it also has the benefit of "decoupling" file equations, CI vars,
JCWs
-
JavaTelnet communication probably less efficient than child process communication
-
child processes could use e.g. pipes, shared memory, user mapped files
-
however, this would need more programming in servlet and native code
-
telnet sessions give flexibility of local or remote MPE program execution
Misc
-
Web Server and Java servlet can run on the 3000 or another machine/platform
-
helpful for aspects like load-balancing, firewalling, etc
-
Servlet side can help with http session tracking (cookies or URL rewriting)
-
probably more convenient than handling it in the MPE program(s)
Examples
Please notice that the Proglet servlet and examples are just rough prototypes.
Use and enhance at your own risk!
-
Proglet.java is the servlet that interfaces
the MPE "programs" (via HostIO.java)
-
CmdFile1.txt provides a simple HTML form and
response
-
CmdFile2.txt provides access to a few MPE commands
and their output
-
TranXL1.txt provides a simple HTML form and response
(in Transact/XL)
-
TranXL2.txt provides access to the TurboIMAGE
sample database Music
-
PasXL1.txt provides a simple HTML form and response
(in Pascal/XL)
You can run the above examples from Apache JServ or the servletrunner that
comes with the Java Developer Kit.
Note that the Transact/iX examples above are just used to demonstrate integration
with MPE specific code (and because they allow coding TurboIMAGE access
quite conveniently). The Command File examples show that there is nothing
Transact specific about the MPE Proglet approach. You can easily implement
examples in other programming languages, like COBOL, Pascal, C, Fortran,
or Basic. I'd be happy to receive contributions in this regard ;-)
Lars Appel, 24-Apr-00 .. 15-May-00