Developer

Learn to use ASP objects and components

Interact with browsers and servers with ASP objects, and simplify common procedures with ASP components.

By Amy Cowen
(6/29/99)

ASP objects lets you interact with both the server and the browser, and you'll routinely use one or more objects within your ASP scripts. You don't have to install anything to use them, but you do have to remember to open and close them.

ASP components, on the other hand, are ActiveX controls that interface with ASP to simplify common procedures. Some commonly used objects and components are defined below.

Objects

Request Object
The Request object lets you tap into the information passed through an HTTP request. You can use the Request object to parse encoded URLs, access information from a form, and read cookies, client certificates, and the HTTP headers.

Response Object
The Response object is your key to sending information to the user. You can write to the screen, redirect to another page, and create cookies using the Response object.

Application Object
The running Web server is an application. Using the Application object, you can control features related to starting and stopping the application, as well as store information that should be accessed by the application as a whole.

Server Object
The Server object lets you perform routine functions, such as mapping a virtual path to a physical one and creating an instance of a component.

Session Object
Using the Session object, you can store information related to each user who is visiting your site.

Components

Ad Rotator
The Ad Rotator streamlines the process of setting up a delivery system for your banner ads. In a separate file, you store information regarding the banner. The component then delivers a randomly selected banner every time the page is loaded.

Browser Capabilities
The Browser component lets you determine what browser a user is using and what features are supported by that browser.

Collaboration Data Objects (CDO)
Tied in with the IIS SMTP server, CDO lets you send and receive email. With CDO, for example, you can process a form without relying upon a Perl script and CGI.

Content Linking
This is a handy object for creating a linear or sequential pathway through your site or a subsection of the site. You maintain a simple text file that lists the files in the proper sequence. Simple next and previous links then can be added to the page, and a table of contents can be easily generated.

Content Rotator
If you have a need for rotating content, this will be a favorite component. It is easy to use and allows you to add dynamic content to any page without using a database. In a separate text file, you store chunks of HTML code that you want alternately dropped into a space on the page. The Content Rotator will display one of the chunks each time the page is reloaded.

Database Access
Using this component, you can hook into a database to write contents to the browser screen and to create or update existing database files.

Third-Party Components

There are numerous third-party components—both free and fee-based—available for ASP. If you're running your own server, you can install components at will. Registering a .dll is often the extent of the installation, so a component can be a real time-saver. Instead of spending hours re-creating the wheel, check to see if a component exists to handle the task at hand.

If your site is hosted by an ISP, you may not be able to install your own components or even have them installed, so check with your ISP's support team.

Editor's Picks

Free Newsletters, In your Inbox