Sideway from Sideway
Draft for Information Only


ASP Element
Scripting Language
ActiveX Script
ASP Object
ASP Components
ASP Output Directive
ASP Processing Directives
Server-Side Script
Server Side Include File
ASP Keywords

ASP Element

ASP Element of a ASP file is a division of scripting commands. The scripts are enclosed by delimiters "<%" and "%>". The HTML tags are transferred to the browser directly, but the scripts between the delimiters "<%" and "%>" will be interpreted on the server by the ASP engine. The delimiters "<%" and "%>" can be either on the same line with the scripts

<% Response.Write ("<h1>ASP Sample</h1>") %>

or on an individual line.

Response.Write ("<h1>ASP Sample</h1>")

And, the space between the delimiter and script is not necessary because ASP engine removes white space including spaces, tabs, returns, and line feeds from both VBScript and JScript command of an ASP file. But for other scripting languages, the ASP engine preserves white space so that scripting languages dependent upon position or indentation can be interpreted correctly.

<%Response.Write ("<h1>ASP Sample</h1>")%>

Comment the script between the delimiters can be done by placing an apostrophe(') at the beginning of a line. And it is better to place another apostrophe(') at the end of a line for better compatibility with JScript. Unlike the HTML comments and client-side  scripting comments, the server-side comments are removed by the interpreter during processing and no server-side comment will be sent to the browser.

<% ' comment %>

Scripting Language

ASP engine of Internet Information Server provides native support for both Microsoft VBScript and JScript. Both VBScript and JScript can be used as the scripting language for ASP. The default scripting language is VBScript. The scripting language is the tool used as the programming language for web application development. The scripting language allows the web site builder to customization their web site by making use of the conditional and looping statements, and the built-in functions

VBScript is a subset of Visual Basic. The functions of VBScript on the server used with ASP is limited. The variables used in VBScript are of type variant. Variables can be used without declaration. Conversion functions are available for different data types conversion whenever necessary. The option of specifying the lower bound of a array is not available and the default low bound value is zero. Besides VBScript cannot interact with the Windows API directly unless the Windows API is packed as an ActiveX objects. But only two ActiveX commands are supported.

The scripts between delimiters "<%" and "%>" are VBScript commands to be interpred by the ASP engine. A line break is used to indicate the end of a VBScript command.

Response.Write ("<h1>ASP Sample</h1>")
Response.Write ("<h2>ASP Statement</h1>")

Multiple VBScript commands can also be put on a single line if these commands are seperated by a colon.

Response.Write ("<h1>ASP</h1>") : Response.Write ("<h2>Statement</h2>")

For a very long VBScript command, the command can go multiple lines by adding a underscore preceded by a space at the end of the line.

Response.Write "<h1>ASP Sample</h1>" & _
"h2>ASP Statement</h2>"

ActiveX Script

Besides VBScript and JScript, other third-party ActiveX compliant Scripting engines can also be used. The key feature of these ActiveX Scripting engines is the capability of calling ActiveX objects and the built-in ASP objects. For VBScript,  the ActiveX commands are:

Set aspadrot=Server.CreateObject("MSWC.AdRotator" )
Set aspadrot=nothing
<%Response.Write aspadstr%>

ASP Object

The ASP technology is a technology for creating dynamic web pages by making use of scripting commands and reusable ActiveX server objects. Objects used in ASP technology resemble other Onject Oriented Programming Languages. The creation of ASP technology is to simplify the development of a dynamic web application. Therefore standard ASP objects are built-in with ASP technology to handle the interaction between the server and the client,  and to store and to gather necessary information for the web application. These built-in ASP objects are ASP intrinsics created for global use and no instance of the object is needed to be created before using these built-in ASP objects.  The built-in ASP objects are:

  • Server Object: provides a mean to access the methods and properties of the object with different types of server tasks on the server. The Server Object can be considered as a utility functions set of the Web Server
  • Application Object: provides a mean to access the methods, properties, events and collections of the object related to web appliction to store and to share information among all clients at an web application level. The Application Object can be considered as an application config or setup functions set of the entire Web Application
  • Session Object: provides a mean to access the methods, properties, events and collections of the object related to the session of a client user to store and to share information about the client on the server during a session. The Session Object can be considered as a client tracking functions set of the Web Server
  • Request Object: provides a mean to access the methods, properties, and collections of the object related to the HTTP request from a client user to retrieve and to store information that passed by the client to the server during a HTTP request. The Request Object can be considered as a request receiving functions set of the Web Server
  • Response Object: provides a mean to access the methods, properties and collections of the object related to the HTTP response to a client user to send and to store information that passed to the client by the server during a HTTP response. The Response Object can be considered as a response sending functions set of the Web Server
  • ObjectContext Object: provides a mean to access the methods and events of the object related to the transaction processing initiated by ASP script in an ASP page to commit or to abort a transaction managed by Component Services. A @Transaction directive is needed to instruct the web server to run in a transaction. The transacton can either be succedds completely or fails. The ObjectContext Object can be considered as the transaction states functions set of the Web Server
  • ASPError Object: provides a mean to access the properties of the object related to the error condition of processing the script in an ASP page The properties of an ASPError Object is read-only only. The ASPError Object can be considered as the error codes set of the Web Server
  • ScriptingContext Object: Obsolete and is removed in IIS 4.0. Replaced by the COM+ ObjectContext object.

ASP Components

An ASP component is an executable self contained code with specific functions designed for providing one or more objects by performing those specific functions within the component. In general, an object instance is collections of information with specific methods to carry out some predefined procedures for manipulating the properties of an instance of an object by modifying its attributes created by the execution of the corresponding ASP component. An instance of the object can be created by assigning a new variable name to the ASP object provided by the ASP component using the ASP Server.CreateObject method. Since the ASP Server.CreateObject method needs the registered name of the ASP component, the ASP component should be registered before the ASP component can be used to provide ASP objects. 

To enhance the usability of ASP technology, some built-in components are available to manipulate and to access the data, files and file system on a server. For example

  • Set fso=Server.CreateObject("Scripting.FileSystemObject")
  • Set d=Server.CreateObject("Scripting.Dictionary")
  • Set conn=Server.CreateObject("ADODB.Connection")
  • Set comm=Server.CreateObject("ADODB.Command")
  • Set rs=Server.CreateObject("ADODB.Recordset")
  • Set strm=Server.CreateObject("ADODB.Stream")

Besides, there are also some base components to enrich the pre-made functions of ASP technology

  • Set adrot=Server.CreateObject("MSWC.AdRotator")
  • Set brow=Server.CreateObject("MSWC.BrowserType")
  • Set nxlk=Server.CreateObject("MSWC.NextLink")
  • Set ctrot=Server.CreateObject("MSWC.ContentRotator")
  • Set pgcount=Server.CreateObject("MSWC.PageCounter")

ASP Output Directive

ASP support the output directives <%= expression %> to displays the value of an expression. The output directive is equivalent to the Response.Write method to display the value of an parameter.

ASP Processing Directives

Each ASP page can have individual control setting for processing the ASP files. ASP support @processing directives, which must be the first command within the ASP page, usually placing at the begining of an ASP file to pass information to the web servre on how to process the ASP file.

  • @CODEPAGE: to specify the literal strings encoding in a web page
  • @ENABLESESSIONSTATE: to turn off session tracking for a web page
  • @LANGUAGE: to set the programing language for interpreting the scripting commands
  • @LCID: to specify the display format of dates, times and currencies in a web page by locale identifiers
  • @TRANSACTION: to specify the scripting command of the ASP page is treated as a transaction for activating the component services to create a transaction for coordinate the resources updating. That is  to specify the ASP file to run under a transaction context


Besides the processing setting of an ASP file, ASP also support a global control setting for the application by placing a global.asa file in the root directory of the application. This is an optional file and an application can only have one global.asa file control setting only. The contents of a global.asa file are

  • Events of ASP built-in object in four division:
    • Application_OnStart
    • Application_OnEnd
    • Sesson_OnStart
    • Sesson_OnEnd
  • Declarations of object
  • Declarations of typelibrary

Server-Side Script

Another useful feature of ASP technology is the server-side script <SCRIPT runat="server> element. This feature allows the resembling of multilines of inline script of a specific purpose into a modular base functional module.

<script language = "vbscript" runat = "server">
function strCutName(strName)
strCutName = Right(strName, 3)
end function

Server Side Include File

In order to increase the flexibility and reusing of existing contents, ASP provide a server-side include directive #include directive for inserting the content of one file into a file before the web server processing it. Therefore some common functions, headers, footer, or elements can be reused on multiple pages. Because the #include directive is used to insert a file into the ASP file before the ASP engine processing it, the #include directive is placed outside the ASP delimiters for easier to manage. Instead of using a new HTML tag, the #include directive is placed inside a HTML comment tag for preventing the #include directive rendered in the HTML document by mistake. Usually the #include directive is placed immediately after the open comment character with a preceded space. The  #include directives are 

  • <!-- #include virtual ="/virtual/" --> for a included file with a virtual directory
  • <!-- #include file ="files\" --> for a included file with relative path

There is no special requirement on the file name extension. The file name extension of an included file can be .inc for easier to distinguish them from other types of files. But the file name extension of an included file can also be .asp so that these file will be interpreted before response to the client.

ASP Keywords

The following are ASP keywords which are predefined reserved identifiers corresponding to ASP page directives, the ASP built-in objects, or intrinsic objects, andr global.asa elements respectively that have special meanings to the compiler.

  • ASP page directives
    • @LCID
  • ASP built-in objects
    • Application
    • ASPError
    • ObjectContext
    • Request
    • Response
    • Server
    • Session
  • ASP Application
    • Application_OnEnd (event)
    • Application_OnStart (event)
    • Contents (collection)
    • Lock (method)
    • Remove (method)
    • RemoveAll (method)
    • StaticObjects (collection)
    • Unlock (method)
  • ASP ASPError
    • ASPCode (property)
    • ASPDescription (property)
    • Category (property)
    • Column (property)
    • Description (property)
    • File (property)
    • Line (property)
    • Number (property)
    • Source (property)
  • ASP ObjectContext
    • OnTransactionAbort (event)
    • OnTransactionCommit (event)
    • SetAbort (method)
    • SetComplete (method)
  • ASP Request
    • BinaryRead (method)
    • ClientCertificate (collection)
    • Cookies (collection)
    • Form (collection)
    • QueryString (collection)
    • ServerVariables (collection)
    • TotalBytes (property)
  • ASP Response
    • AddHeader (method)
    • AppendToLog (method)
    • BinaryWrite (method)
    • Buffer (property)
    • CacheControl (property)
    • Charset (property)
    • Clear (method)
    • CodePage (property)
    • ContentType (property)
    • Cookies (collection)
    • End (method)
    • Expires (property)
    • ExpiresAbsolute (property)
    • Flush (method)
    • IsClientConnected (property)
    • LCID (property)
    • PICS (property)
    • Redirect (method)
    • Status (property)
    • Write (method) 
  • ASP Session
    • Abandon (method)
    • CodePage (property)
    • Contents (collection)
    • LCID (property)
    • Remove (method)
    • RemoveAll (method)
    • Session_OnEnd (event)
    • Session_OnStart (event)
    • SessionID (property)
    • StaticObjects (collection)
    • Timeout (property)
  • ASP Server
    • CreateObject (method)
    • Execute (method)
    • GetLastError (method)
    • HTMLEncode (method)
    • MapPath (method)
    • ScriptTimeout (property)
    • Transfer (method)
    • URLEncode (method)
  • ASP custom object
    • OnEndPage (event method)
    • OnStartPage (event method)

The complete list of ordered ASP keywords

  • @LCID
  • Abandon
  • AddHeader
  • AppendToLog
  • Application
  • Application_OnEnd
  • Application_OnStart
  • ASPCode
  • ASPDescription
  • ASPError
  • BinaryRead
  • BinaryWrite
  • Buffer
  • CacheControl
  • Category
  • Charset
  • Clear
  • ClientCertificate
  • CodePage
  • Column
  • Contents
  • ContentType
  • Cookies
  • CreateObject
  • Description
  • End
  • Execute
  • Expires
  • ExpiresAbsolute
  • File
  • Flush
  • Form
  • GetLastError
  • HTMLEncode
  • IsClientConnected
  • LCID
  • Line
  • Lock
  • MapPath
  • Number
  • ObjectContext
  • OnEndPage
  • OnStartPage
  • OnTransactionAbort
  • OnTransactionCommit
  • PICS
  • QueryString
  • Redirect
  • Remove
  • RemoveAll
  • Request
  • Response
  • ScriptTimeout
  • Server
  • ServerVariables
  • Session
  • Session_OnEnd
  • Session_OnStart
  • SessionID
  • SetAbort
  • SetComplete
  • Source
  • StaticObjects
  • Status
  • Timeout
  • TotalBytes
  • Transfer
  • Unlock
  • URLEncode
  • Write


ID: 120100021 Last Updated: 20/12/2012 Revision: 1 Ref:



  1. Active Server Pages,  
  2. ASP Overview,  
  3. ASP Best Practices,  
  4. ASP Built-in Objects,  
  5. Response Object,  
  6. Request Object,  
  7. Server Object (IIS),  
  8. Application Object (IIS),  
  9. Session Object (IIS),  
  10. ASPError Object,  
  11. ObjectContext Object (IIS),  
  12. Debugging Global.asa Files,  
  13. How to: Debug Global.asa files,  
  14. Calling COM Components from ASP Pages,  
  15. IIS ASP Scripting Reference,  
  16. ASP Keywords,  
  17. Creating Simple ASP Pages,  
  18. Including Files in ASP Applications,  
  19. ASP Overview,  
  20. FileSystemObject Object,  
  22. ADO Fundamentals,  

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna

Home 5






Hobbies 7


Chinese 1097

English 337

Reference 67


Hardware 149


Application 187

Digitization 24

Numeric 19


Web 757



Regular Expression 1


Knowledge Base

Common Color 1

Html Entity (Unicode) 1

Html 401 Special 1

OS 389

MS Windows

Windows10 1

.NET Framework 1

DeskTop 7



Formulas 8

Algebra 20

Number Theory 206

Trigonometry 18

Geometry 18

Calculus 67

Complex Analysis 21


Tables 8


Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5


Process Control 1

Acoustics 19

FiniteElement 2


Electric 10

Biology 1

Geography 1

Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 06 September 2019