ASP Java Component Framework

The Microsoft Active Server Pages (ASP) Java Component Framework simplifies the creation of Active Server components by adding new interfaces. The goal is to retain all of the features and flavor of the ASP programming model, but to present that model in a format that is more familiar to Java programmers. The classes use native Java types, and support native Java interfaces. 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, the standard Java associative collection class.

Reference Pages

For detailed information about each of the Java Component Framework classes, see the reference pages listed below.

Request Server ObjectDictionary
Response AspContext RequestDictionary
Session CookieDictionary Map
Application Cookie Enumerator

Using the Java Component 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 where the Java VM can find them. Do this by performing the following steps:

  1. Create a new directory named "aspcomp" in your java\TrustLib directory. This directory is usually found in the %windir% folder. 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 the samples directory for information on how to install these on your system.

Creating Components

First, a little terminology. Building a component in Java means creating a single Java class that you will instantiate from ASP as a COM object. This class is called 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 Component Framework is easy; you can create a component by following these 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 your component’s Java class with COM, so that it can be created (with COM) from an ASP. 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:
  4. javareg /register /class:[<packagename>.]<classname> /progid:<progid>

For more information on registering a Java component, enter "javareg/?" at the C: prompt.