Sideway
output.to from Sideway
Draft for Information Only

Content

ASP Element
Scripting Language
ActiveX Script
ASP Object
ASP Components
ASP Output Directive
ASP Processing Directives
Global.asa
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" )
aspadrot.Clickable=false
aspadstr=aspadrot.GetAdvertisement("schedule.txt")
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

Global.asa

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
</script>

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/file.inc" --> for a included file with a virtual directory
  • <!-- #include file ="files\file.inc" --> 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
    • @CODEPAGE
    • @ENABLESESSIONSTATE
    • @LANGUAGE
    • @LCID
    • @TRANSACTION
  • 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

  • @CODEPAGE
  • @ENABLESESSIONSTATE
  • @LANGUAGE
  • @LCID
  • @TRANSACTION
  • 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

©sideway

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

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

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

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


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