Script writers often find that they need to accomplish certain tasks in their scripts on a regular basis. For example, you might have a number of scripts, all of which ultimately perform different tasks, but all of which need to get information from a user. Objects save you the labor of reinventing the wheel every time you need to perform such a common task. An object is a combination of programming and data that can be treated as a unit.
To use most objects, you must first create an instance of that object. (For more information about creating instances of objects, refer to Working with ActiveX Server Components.) However, Active Server Pages (ASP) includes five objects that do not require instantiation. The following table summarizes these built-in objects, the tasks they are used for, and where to look for examples.
| Object | Task | Examples |
|---|---|---|
| Request object | Get information from a user. | Getting Information from a User |
| Response object | Send information to a user. | Sending Information to a User |
| Server object | Control the ASP execution environment. | Working with ActiveX Server Components |
| Session object | Store information about a users session. | Developing ASP-Based Applications |
| Application object | Share information among users of an application. | Developing ASP-Based Applications |
The syntax by which you gain access to an object depends on the scripting language you are using. Because the default primary scripting language of ASP is VBScript, the examples that appear in this guide use VBScript syntax, except where noted otherwise. If you want to use another scripting language, refer to that languages documentation for the appropriate syntax to work with objects. (Refer to Using Scripting Languages for more information.)
The Request and Response objects contain collections. A collection is a set of related pieces of information that are accessed the same way. See Getting Information from a User and Sending Information to a User for information about accessing these collections. You can also gain access to information in a collection by using the For...Each statement. This statement is useful in debugging scripts; see Debugging Active Server Pages Scripts for more information.
You gain access to objects from a script by using methods and properties.
A method is a procedure that acts on an object. The general syntax is
Object.Method parameters
Where parameters may be a variant, data, a string, or a URL, depending on the method; refer to Object Reference for more information about a specific method.
A property is a named attribute of an object. Properties define object characteristics, such as size, color, and screen location; or the state of an object, such as enabled or disabled. The general syntax is
Object.Property parameters
Where parameters may be a value, string, or flag, depending on the property. Refer to Object Reference for more information about a specific property.