ASP Java Component Framework

The Active Server Pages Java Component Framework simplifies creating Active Server Components by creating new interfaces that expose the ASP object model. The goal is to retain all of the features and flavor of the ASP Programming model, but to expose it in a way that is more natural for the Java programmer. The classes use native Java types, and support native Java interfaces. So, for example, the Application and Session objects, which allow the programmer to store data and associate it with a name, extend the class java.util.Dictionary, which is the standard Java associative collection class.

Reference Pages

The following are links to the Reference pages for the framework classes.

Request

Enumerator

 CookieDictionary

Response

Server

 ObjectDictionary

Session

Cookie

 RequestDictionary

Application

 Map

 

Using the Framework Classes

The framework has been provided in both source code (.java) and compiled byte code (.class) formats. In order to use the classes, though, you'll have to put them in a place that the Java VM can find them. Here's what to do:

  1. Create a new directory, "aspcomp" in your java\trustlib directory. This is most typically found in %windir%\java\TrustLib. Since the framework files have been created in a package called aspcomp, the java vm will expect to find them there.
  2. Copy the framework files to the newly created java\TrustLib\aspcomp directory.

Using the Samples

The Additional Samples directory contains sample .java (and .class) files that are based on the framework classes, as well as .asp files that use them. See the readme.txt file in samples directory for information on how to install these on your system.

Creating Components

First, a little terminology. When we say that we want to build a component in Java, what we mean is that we want to create a single Java class that we will instantiate from ASP as a COM object. We call that class "the component class". It is entirely possible that the component will create other Java objects or COM objects, which it uses internally. So, while the source code for your component might consist of multiple Java source files, there will be a single Java class that represents your component.

Creating components with the Java Framework is very easy, and requires 3 basic steps:

  1. Create the .java file(s) for your component. Make sure that you include the "import aspcomp;" in your source.
  2. Compile the files to produce .class files.
  3. Register the your componentÆs Java class with COM, so that it can be created (via COM) from an Active Server Page. You do this by running the javareg.exe tool that comes with the Microsoft SDK for Java. Note that you only need to do this registration once, and you only need to register the class that is your component. The following line shows how to register a component

javareg /register /class:[<packagename>.]<classname> /progid:<progid>