Accessing Built-In ASP Objects

The Java Component Framework was designed to make accessing the ASP built-in objects from a Java component simple. The framework does this by hiding many of the intricacies of COM object programming from you, allowing you to focus almost exclusively on enhancing the functionality of your component. It is still important, however, to have some understanding of what's happening under the hood. This sample demonstrates the steps that would be necessary to access, and invoke a method in, the built-in Response object if you were not using the Java Component Framework.

This sample uses the GetObjectContext to get a reference to the interface for the context properties, and then uses the GetProperty method of the context properties to get a reference to the actual Response object. Finally, the getDispatch of the Response object is called to get a pointer to the actual dispinterface for the Response object. In this sample, the dispinterface is used to invoke the Write method of the Response object and send "Hello, World!" to the client browser.

These steps are fairly straightforward, but the Java Component Framework makes it even easier by providing methods that you can use to immediately gain access to the correct ASP objects. The framework's AspContext.getResponse method, for example, consists of code that looks very much like the code in this sample, but it also includes error trapping and additional functionality that would be tedious to implement for every single Java component that you create.

This sample is provided for educational purposes only. It has not been tested in a production environment, and Microsoft® will not provide technical support for it.

This project is available in the ...\iissamples\sdk\components\java\Samples subdirectory of the Internet services directory.


© 1997 by Microsoft Corporation. All rights reserved.