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