Chapter 18. XML Legacy Gateway 571
18.3.1 Sample servlet
The sample servlet renders host data windows in an HTML format and posts
these windows to a Web browser. This sample is a subset of the servlet which
Host Publisher uses to perform that same function as part of the Host Publisher
XML Legacy Gateway feature. As such, the sample has been simplified to
provide the Java programmer with the essentials for creating an application that
can interface to host application windows using an XML interface. The source
code is provided in the SDK and is documented throughout with comments so
that the programmer can understand the necessary steps involved in writing
similar servlets. This sample displays every host application window to the user.
A more typical application may seek to drive several application windows
automatically, and only display to the user a few pieces of data from the host
application windows. The user may then input data into the HTML form; the
application can then drive more host windows with this input, and so on.
The general flow of the servlet processing is as follows:
1. The user first accesses the servlet, causing the xmlLegacyGWSample servlet
to be instantiated and the doGet method to be invoked.
2. The servlet receives the host connection parameters via the parameters
passed with the URL.
3. The servlet sets up a hashtable to store these values, along with other initial
values. This hashtable is stored in a vector, which is then stored in a static
hashtable. The key value for the vector in the static hashtable is the Web
session ID. This allows for multiple instances of the servlet, for the same Web
session ID, to be easily manipulated.
4. The doGet method will also initialize an IBM Host On-Demand (HOD)
properties object, to be used for establishing a connection to the host.
5. An xmlLegacyProcessSample object is then instantiated and the first access
method of this object is called.
6. The xmlLegacyProcessSample object then uses the stored parameters to
establish a connection with the host. This is done by instantiating a Host
Publisher HostConnection JavaBean, and calling the acquireHostConnection
method. This function will return an HOD Session JavaBean.
7. The xmlLegacyProcessSample object will then instantiate a Host Publisher
xmlAppData JavaBean, and wire this bean to events generated by the HOD
Session bean.
8. The xmlLegacyProcessSample will then wire itself to events generated by the
xmlAppData bean. In this way the xmlLegacyProcessSample bean can
communicate with the xmlAppData bean using XML data formats, and the
572 IBM WebSphere Host Publisher Version 3.5
xmlAppData bean communicates with the host using the HOD Session bean.
This path yields the desired XML data interface to a host application.
A block diagram of the relationship of these components is illustrated in
Figure 18-2
Figure 18-2 XML Legacy Gateway architecture
When the xmlAppData bean signals that it has received data from the host, the
xmlLegacyProcessSample object retrieves this data in XML format. It then
combines this data with a stylesheet (an XSL file) using a stylesheet processor
that is included in IBM's WebSphere product. This process produces HTML
output. The HTML output contains JavaScript calls. The JavaScript file is called
lxgwfunctions.js, and is included in this sample.
The user then is presented with the host window, and is able to fill in the input
data fields and select an action to take on the windows (for example, Enter, PF1
function key, PF3, and so on) by clicking one of the buttons presented on the
HTML page.

Get A Comprehensive Guide to IBM WebSphere Host Publisher Version 3.5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.