Embedding Active Content in Janus Web Server Applications


Introduction


Janus Web Server applications can be greatly enhanced through the use of Java programs and other active content. This document gives a brief overview of Java, and describes some of the ways database applications can be written using Java. Techniques discussed are:
  1. passing data as applet parameters,
  2. the Java openConnection(URL) method,
  3. Java Database Connectivity (JDBC),
  4. JDBC-to-ODBC bridges, and
  5. proprietary "hub" servers.
Janus Web Server applications are uniquely positioned to use this technology because of being tightly integrated with the Model 204 database.

A short history of active content on the web


The model for World Wide Web applications is built on a platform whose original intent was the sharing of textual documents. Over time the transport protocols and markup languages that make the web work (http, ftp, html, etc.) have been extended to allow the embedding of increasingly complex objects, from static graphics and sound to movie clips and, with the advent of Java, entire applications.

The Java programming language was originally developed by a team headed by James Gosling at Sun Microsystem's Mountain View, California site. The project began in 1990 and the orginal conception was for a language that could survive in the fast-changing world of programmable consumer devices. The chips on which set-top-boxes, remote controls and other consumer electronics are based change at a blinding rate, so Java was designed to be chip-independent, meaning programs could be reused even as hardware platforms evolved. This platform independence resulted in Java being perfectly positioned just as the web reached a point of complexity where an embeddable, platform-independent programming language was needed. Java is now such a force in the industry that Sun has an entire subsidiary, JavaSoft devoted to the language.

In the short time since a commercial version of Java has been available, a huge market has developed around and in competition with Java. JavaSoft itself provides a free version of the language and a character mode compiler known as the Java Development Kit or JDK. More complex integrated development environments are available from vendors such as Microsoft -- Visual J++ -- Symantec -- Symantec Cafe -- and others. In addition, a number of competing embeddable languages have been developed or retrofit to the Web application model, including Microsoft's extensions to Visual Basic, known as ActiveX and Sybase's web-enabling technology for PowerBuilder. Applications written in these and other languages and designed to run inside a web browser framework are known collectively as active content.

Active content provides more direct control of the user interface than simple html form tags, and allows web browsers to perform client-side validation of input or complex operations prior to sending data to the server, reducing network traffic and giving the user a more immediate and satisfying experience of the web.

Applets

While Java can be used like C++ to write full GUI or character-based applications, it can also be compiled into an applet. An applet is a special compilation of Java that runs only inside a Java-enabled web browser, and it's usually applets that are being referred to when Java is mentioned. An applet conforms to certain restrictions that extend and improve on the basic client-server application model:

An applet is dependent upon the browser for start, stop, display, print and other services.

JanWeb and Active Content

The first commercial version of Java emphasized graphics presentation, so the majority of applets on the web are simple animations, like the one at the top of this page. Java animation offers advantages over other types of animations in that a single image can be sent with the program, and the Java applet can manipulate it to create animation frames. While this saves considerable bandwidth it's not a terribly compelling reason for Sirius' JanWeb customers to implement Java applications in their database systems.

Recent releases have broadened Java's capabilities, and standards are emerging for data connectivity and download which will make Java the flexible enterprise environment required by database shops.

At the moment there are about half-a-dozen methods by which a Java program can act as a client to a database system. Following is a discussion of some of these methods. The Janus Web Server like any full-featured web server supports all these methods, and has the advantage of being integrated with our clients' mission critical database. This tight integration makes it even easier to implement active content applications.

Remember that with all Java applets connections can only be opened on the host machine that sent the Java class to the browser. This is one of the most important security restrictions in Java.

Downloading data as Applet Parameters

If you use your browser's "view source" function on this page, at the bottom you will see the applet tag for a Java applet that displays hit counts on the Sirius web site by hour for the last 24 hours. The "param..." tags are the input data to the Java applet, and to refresh the data you simply hit your browser's refresh key. This is a very simple, efficient method by which a Java program can be sent to a browser and the input to the program refreshed without having to write a lot of fancy Java timer logic, or use a database connectivity package. You could use this method to send and display stock quotes, Model 204 performance data or file statuses, or any data that changes over time and is stored on the server and for which you don't mind the user having control over the refresh interval.

This data access method is especially convenient when using Janus Web Server, as the entire page can be dynamically generated, as most of Sirius' pages are, including the Java input parameters.

We've also implemented a SIRFILE demonstration that allows you to specify chart settings, then resubmit the entire page from a form.

The openConnection(URL u) Method

Aside from the previously discussed technique, openConnection is considered the "crudest" host access method. openConnection is a programmatic way to send a URL request to the host exactly as if a hot link was pressed on an html page. The Java applet receives the returned data as an input stream, and must parse and handle whatever comes back from the host. If you have access to a Java class browser see the class java.net.URLStreamHandler for a description of this method.

The downside of using openConnection(URL) is the responsibility for parsing the input stream and the fact that URL requests may not work under certain firewall configurations.

Sirius does not yet have a sample program for this access method.

JDBC

Java Database Connectivity, or JDBC, is the Java database access method with the most industry momentum behind it. JavaSoft has an extensive list of drivers and vendors that support JDBC. JDBC drivers break down into 4 categories,
  1. Bridge drivers, described in the next section.
  2. Native-API, Part-Java drivers. These are proprietary drivers which connect to specific databases. Like bridges, these drivers require some client machine configuration and loading of binaries onto client machines. Drivers are currently available for DB/2, Oracle and Sybase. These drivers, while not recommended due to their platform and vendor dependence, can be used from inside Janus Web Server appilications as long as they connect to databases on the same machine as Model 204.
  3. "Net-protocol, part-Java drivers, described below.
  4. 100% Java drivers.
In keeping with Java's platform independence, the obvious best solution is a 100% Java JDBC driver. Again, a number of such drivers are discussed at the JavaSoft site. Sirius is currently trialing the drivers from Connect Software, which seem like a solid implementation. Other drivers are available from Borland, SAS and Imaginary.

There are a number of implementation issues to work out when using JDBC drivers, the most significant of which is that the drivers cannot be kept in a "java.*" package. Under the current Java security scheme, packages beginning with "java.*" are under the exclusive control of JavaSoft, and may not be downloaded -- they must be part of the browser-bundled Java runtime environment. Therefore if you implement one of the beta-jdbc packages you'll have to support something like a "jdbc.*" package, and probably rename this package to "java.*" once Java allows it. This is a minor issue if you implement cleanly, perhaps keeping all non-Java classes in their own Model 204 file, or certainly in their own directory structure.

JDBC-to-ODBC Bridges

Bridge connectivity allows Java's JDBC methods to be translated into ODBC calls to a database. This might seem an attractive alternative to shops already using ODBC, but JavaSoft specifically recommends against using bridges, both to avoid client-configuration problems and to keep your Java implementation platform independent.

Proprietary Database Hubs / Net-Protocol Drivers

A number of vendors are offering hubs through which their proprietary Java methods can connect to other data sources. They all work approximately the same way: A Java applet is written using the vendor's proprietary Java classes which allow communication with their generalized server. This server may act either as a datasource itself or may pass requests onto other servers or other datasources on the same server. The point of this centralized connectivity is to overcome Java applets' security restriction that connections can only be opened on the host machine that sent it.

Of course, this imposes the restriction that your web server reside on the same machine as the proprietary data hub. In addition the Java applets written to this centralized server will have to use the vendor's proprietary methods. Symantec's dbAnywhere is one such implementation. This data access method doesn't directly benefit Janus Web users as none of the centralized hubs work on IBM mainframes, although Model 204 could be accessed from the hub through a Janus Open Server or Omni connection.

Java Implementation Issues

The Java language is distributed in packages. For example the package java.applet contains the classes used to create applets, and classes in java.awt (the Abstract Windowing Toolkit) are used for graphical presentation services. All Java's native packages begin with "java."

Because Java is object oriented, it is easily extensible and there is considerable competition in the marketplace to extend Java in proprietary directions. Sun promotes a "100% Pure Java" initiative intended to keep mainstream Java use platform independent and in line with their development direction. Of course all vendors have their own marketing agendas and Sun is no exception, but you're sure to have an easier time maintaining a system if you conform to the dictates of this initiative, especially during the current early stages of data access and security development at JavaSoft.

Other vendors, not constrained by Sun's wide ranging goals for Java, offer class libraries that extend Java far beyond the current state of 100% Pure Java art. In fact, if you use any integrated development environment outside the standard JDK you are likely to be using that vendor's specialized class library. When a Java class (an executable) is developed using only JavaSoft's standard methods, the class is the only file that the browser has to download the java.* classes themselves are included in the browser. The RIPPLE animation and the GRAF class used at the top and bottom of this page are such applets.

If Symantec Cafe is the development environment, or Microsoft's J++, or if a JDBC library is being used, the super-classes for these packages must reside on the same server as the applet so client browsers can request classes as needed. It's best to think out your development strategy and try to implement large projects using a restricted set of tools and a single, standard JDBC package so the JanWeb DBA doesn't end up in the business of constantly ftp'ing new versions of packages into the Janus Web Server.

Other Resources

The number of online Java tutorials and samples grows so quickly, your best tool for locating them might be a good search engine.

The best source for Java links is Sun itself.

JavaSoft's official source for online applets is Gamelan.

You can also subscribe to the Java developer's newsgroup to keep up with support issues and changes to the language.


By the way: We've used a bit of JavaScript to catch and display some of your browser settings. You can see the JavaScript in the source for this page. The settings are:

navigator.appName navigator.appVersion navigator.appCodeName navigator.userAgent