Sideway from Sideway

Draft for Information Only


ASP is only a server side scripting technology along with some fundamental interface elements from for running script on the server side to create HTML content dynamically. In other words, ASP is only a scripting host for the supported scripting language to provide the interactivity required for a dynamic web application solution on the server side. Script is a small program or a series of instructions written for a command interpreter to interact with the scripting host. A scripting language is needed to use 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. The 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. 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. The default scripting language is VBScript.

ASP Server-Side Scripting

For the client-side scripting,  all script can be placed within the HTML document by the <script> element. That is all script is enclosed by <script></script> tags of the <script> element. The included scripting code in the HTML document will sent to the browser together with the HTML contents. But for the ASP server-side scripting, the file extension of the HTML document should be ended with ".asp" and all ASP command must be delimited with <%...%> otherwise the ASP code or scripts will not be interpreted by the ASP engine. Since the code delimited with <%...%> will be interpred before sending to the browser, the server-side script which compatible with the client-side scripting language can also be placed inside the client-side script. Besides the <script> element with "runat" attribute equal to "server" can also be interpreted as a server-side only function which can be work with the ASP script at the server-side. However, since the server-side <script> element is already running in the server-side scripting environment, the using of delimiters <%...%> in the server-side <script> element will become a syntax error.  Therefore the delimiter "<%" is to pass the control of code interpretation to the ASP engine of the current default scripting and the delimiter "%>" is to return the control of code interpretation to the web server.

ASP script command:

<%strName = "ABCDE" : intCount = 3%>
Cut "<%=strName%>" to "<%=strCutName(strName)%>".
<script language = "vbscript" runat = "server">
function strCutName(strName)
strCutName = Right(strName, 3)
end function
<script type = "text/vbscript">
document.write(Right("<%=strName%>", <%=intCount%>))
end function

HTTP response output:

Cut "ABCDE" to "CDE".

<script type = "text/vbscript">
document.write(Right("ABCDE", 3))

HTML web page output in Internet Explorer:  

Cut "ABCDE" to "CDE". CDE

Scripting Language

The default scripting language of the ASP script programming is VBScript. The default scripting language of ASP engine can also be specified by the preprocessor ASP directive, @LANGUAGE. Since the default scripting language is changed, the ASP engine should return  the control of code interpretation to the web server before the new default scripting language becomes activated, i.e. end the preprocessor ASP directive by "%>" becore continue with other script.

ASP script command:

<%@ language="jscript"%>
<%var strName = "ABCDE";%>
Cut "<%=strName%>" into"<%=strName.slice(0,2)%>"
and "<%=strCutName(strName)%>".
<script language = "vbscript" runat = "server">
function strCutName(strName)
strCutName = Right(strName, 3)
end function

HTTP response output:

Cut "ABCDE" into "AB"
and "CDE".

HTML web page ouput:

Cut "ABCDE" into "AB" and "CDE".

In general, more than one scripting language can be used for the entire ASP application. For example, VBScript in server-side code and JavaScript on the client-side code. Besides server-side script other than the default scripting language can also be used with the HTML document using the <SCRIPT> element with the corresponding scripting language. Whenever there is preprocessor ASP directive, the ASP engine will process first. If the @LANGUAGE directive is present, the ASP engine will set the default scripting language accordingly. Then the ASP engine will first interpret all script in <SCRIPT> element with non-default scripting language before continue with the code after the preprocessor ASP directive.  All script in <SCRIPT> element with default scripting language will be interpretted after processing the whole HTML document. Because of the unexpected sequence of processing the <SCRIPT> element due to the complexity of the script arranged by the ASP engine, the <SCRIPT> element is usually used for containing procedures and functions only. Besides, the client-side script will be interpreted on the client browser whenever necessary.

ASP script command:

<%@ language="jscript"%>
<%strName = "ABCDE"%>
Cut "<%=strName%>" into "<%//=left(strName,2)%>
<%=strName.slice(0,2)%>" and "<%=strCutName(strName)%>".
<script language="vbscript" runat="server">Response.Write("V1 ")</script>
<%="L1 "%>
Cut "<%=strName%>" to "<%=strCutJName(strName)%>".
<script language="jscript" runat="server"> Response.Write("J1 ")</script>
<script language="vbscript" runat="server">Response.Write("V2 ")</script>
<%Response.Write("L2 ")%>
<script language="jscript" runat="server"> Response.Write("J2 ")</script>
<script language = "vbscript" runat = "server">
Response.Write("V3 ")
function strCutName(strName)
strCutName = Right(strName, 3)
end function
<script language = "jscript" runat = "server">
function strCutJName(strName) {return strName.slice(2);}
Response.Write("J3 ")

HTTP response output:

V1 V2 V3
Cut "ABCDE" into "AB" and "CDE".
Cut "ABCDE" to "CDE".
End J1 J2 J3 ".

HTML web page ouput:

V1 V2 V3 Cut "ABCDE" into "AB" and "CDE". L1 Cut "ABCDE" to "CDE". L2 End J1 J2 J3


Since more than one scripting language can be used to build the ASP code, the syntax of ASP page is highly depending on the scripting language used in writing the web application. Aparted from the syntax of scripting language, there are also some basic rules for constructing correctly structured ASP pages.

  • An ASP page file is a text file. There is special limitation on the encoding of the file.

  • The filename extension of an ASP page file should be ".asp" except the global control setting  file , i.e Global.asa for an web application

  •  The file contents can be text, HTML tags, or server-side scripts.

  • A #include directive enclosed in a HTML comment element, e.g. <!-- #include... --> outside of the delimiter <%...%> for inserting the content of one file into the file before interpreted by the web server.

  • All ASP scripts are enlcosed between the delimiter <%...%>. All enclosed scripts will be interpreted by the ASP engine while the others will remain unchanged as original plain text and HTML tags.

  • The HTML <script> element can also be made compatible with the ASP technology by adding extra attributes, i.e. <script language="..." runat=""server">...</script>.

  • @processing directives enclosed by the delimiter <%@...%> placing at the first line of an ASP file to pass information to the web servre on how to process the ASP file..

  • An output directive enclosed by the delimiter <%= expression %>, which is equivalent to the Response.Write method, to displays the result of an expression in the form of plain text.

  • ActiveX Scripting enclosed by the delimiter <%...%> is the fundamental interface elements of the ASP technology from Microsoft. The key feature of these ActiveX Scripting code elements is the capability of calling ActiveX components, ActiveX objects and the built-in ASP objects. Each Active X elements have their only ActiveX scripting syntax.

  • ASP element

    • 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>")

    • 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 '%>

    • A line break can be used to indicate the end of a script command in both VBScript and JScript command of an ASP file.

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


ID: 121200003 Last Updated: 2012/12/17 Revision: 0


Home (1)



HBR (3)



Hobbies (7)


Chinese (1097)

English (334)

Reference (60)


Hardware (148)


Application (187)

Digitization (24)

Numeric (19)


Web (537)

CSS (1)


Knowledge Base

Common Color (1)

Html Entity (Unicode) (1)

Html 401 Special (1)

OS (366)

MS Windows

Windows10 (1)

DeskTop (5)



Formulas (8)

Number Theory (161)new

Algebra (14)

Trigonometry (18)

Geometry (18)

Calculus (67)new


Tables (8)



Process Control (1)

Mechanics (1)

Rigid Bodies

Statics & Dynamics (129)new

Fluid (5)

Fluid Kinematics (5)

Acoustics (19)

FiniteElement (2)

Biology (1)

Geography (1)

Latest Updated Links

Copyright © 2000-2019 Sideway . All rights reserved Disclaimersfacebook last modified on 08 Mar 2018