What is ASP?
Examples ASP Technology ASP Document Examples ASP Element
ASP Mechanism
ASP Additional Information
What is ASP?
ASP is .........
ASP stands for Active Server Pages
ASP is a server side scripting technology from Microsoft.com
ASP files use the extension ".asp" to activate the supported web server to interpret the scipts in the ASP files
ASP uses delimiters "<%" and "%>" as markup tags to specify the beginning and end of the enclosed script commands.
Examples
Examples Of ASP code
ASP VbScript Command:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<% Response.Write ("<h1>ASP Sample</h1>") %>
</body>
</html>
HTTP Response Output:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<h1>ASP Sample</h1>
</body>
</html>
HTML Web Page Embedded Output:
ASP Technology
ASP technology is a server side techonogy to interpret scripts: vbscript, jscript and activeX script: ASP objects and ASP components.
ASP Document
Basic Features of ASP files.........
ASP file is a HTML document with extension ".asp" to describe web pages
ASP file is just a HTML document with script commands enclosed by delimiters
"<%" and "%>"
ASP technology is just an additional scripting engine that allows script command running on the server side.
HTML document contains HTML tags and plain text without script command can also be an ASP file by renaming the extension to ".asp"
ASP technology also enables both ActiveX scripts and ActiveX server components running on the server.
Examples
Examples of ASP page
ASP VbScript Command:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<% Response.Write ("<h1>This is a Sample ASP Page</h1>") %>
</body>
</html>
HTTP Response Output:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<h1>This is a Sample ASP Page</h1>
</body>
</html>
HTML Web Page Embedded Output:
ASP Element
Similar to a html commenting element enclosed by delimiters "<!--" and "-->", ASP elements in a ASP files are enclosed by delimiters "<%" and "%>". ASP elements can also be inserted anywhere in a ASP file provided that the output is
logically correct.
Since ASP scrips are only additional script commands to enhance the dynamicity
of a web page, ASP element is not a necessary element in a ASP file. The
simplest ASP file is a plain html file without any ASP element.
An ASP element is an element with script
<%
...
Script command: vbscript, jscript, ...
...
ActiveX script: e.g. Set Conn =
Server.CreateObject("ADODB.Connection")
...
ASP objects: Request object, Response object, Server object, ...
...
ASP components: e.g. AdRotator components
...
%>
Besides, in order to increae the flexibility of ASP scripting, ASP technology
support the feature of server-side # include directives also allow inserting the
content of another file into the ASP file before processing by the web server.
And the ASP technology also allow adding one single line @ processing directives, which should be
the first command of the ASP page, including server-side script, and is usually
located at the first line of the ASP page, to send information to web
server for controlling how the ASP file to be interpreted by the server. The @
processing directives commond can also be placed in the included file using #
include directive, providing that the @ processing directives commond is the
first command within the ASP page including inserted files. As the ASP
technology is usually used for developing web application, an optional
Global.asa file is available for declaration and storing session and application
information of the ASP application globally at the application level, which can
be accessed by every page in an ASP application. Therefore each application can
only have one Global.asa file and the Global.asa file should be stored in the
root directory of the ASP application also. The Global.asa file of an
application can only be triggered through an ASP page request of the
application. Once the Application_OnStart procedures of the Global.asa file is
processed, the Global.asa file can only be restarted after the completion of the
Application_OnEnd procedures when the application quits unless the Global.asa
file is refreshed after modification, or the Application_OnStart or
Session_OnStart events are triggered, or the application is restarted through
the stopping and starting the web server or the application.
ASP Mechanism
The mechanism of ASP engine in the IIS, tested with vbscript
and jscript,
may be processed as the following order:
When there is an ISAPI filter intalled on the web site, the ISAPI filters are
processed. This is also applied to all applications.
And ASP pages are also processed through an ISAPI extension, ASP.dll. The ASP engine of the web server is only triggered by the requested file of a HTTP request
with a filename extension of ".asp".
In general, the web server will pass the control of a ASP file to the ASP
engine. If a Global.asa file is located at the root directory, the Global.asa of the
application will be processed is the Global.asa file is not running.
The ASP file will be read and cached by the ASP engine. The starting procedure
of the ASP page processing processed by the ASP engine is to reformat the cached
ASP file to a cached intermediate page by inserting the included file to the
cached intermediate page, reformat the ASP script according to the default
scripting language and extracting the server-side script block from the
intermediate page according to the sequence of the lines while the static HTML
codes and the client-side scripts, which be treated as static HTML codes, are retained in the cached intermediate page
remiains unchanged. The inserted included file will be processed
immediately after inserting. The reformat process will only check and reformat
the ASP code blocks within the delimiters <%...%> to proper script statement
according to the default scripting language while all server-side <script>
blocks are seperated from the ASP code blocks for later processing. However only
the location of the code block of the ASP script will be marked in the cached
intermediate page. Since the ASP @processing directives must be the first
command within
the ASP page, if the first ASP command is @processing directives, then the
@processing directives will be processed and be interpreted first to check all
processing directives setup to be used for the ASP page, including all included
files. The @processing directives will not be kept in the cached
intermediate page. Once the default scripting language of the ASP page is
confirmed, the syntax error of the ASP code blocks within the delimiters
<%...%> can then be detected by ASP engine according to specify default
scripting language. If there is no @ language directive, the ASP code will use
vbscript as the default scripting language.
After the completion of reformat the ASP code block, the ASP engine will then
continue to check and reformat all server-side <script> blocks with the default
scripting language only because there is no need to switch the working script
language of the ASP engine. the syntax error of all server-side <script> blocks
with the default scripting language can then be detected by ASP engine according
to specify default scripting language.
After the completion of check and reformat the server-side <script> blocks with
the default scripting language, the ASP engine will then continue to check and
reformat all server-side <script> blocks with one type of non-default scripting
language. Because of compatibility, the working script language of the ASP
engine will switch the same non-default scripting language so that the syntax
error of all server-side <script> blocks with the same non-default scripting
language can be detected by ASP engine according to the same non-default
scripting language.
In order in to reduce the number of switching the working script language of the
ASP engine, the server-side <script> blocks of the same type of non-default
scripting language will be interpreted before used. All coding errors in
the server-side <script> blocks with the same non-default scripting language can
be detected accordingly. The server-side <script> blocks with non-default
scripting language can call functions in server-side <script> blocks with the
same non-default scripting language because these functions can be interpreted
immediately. However, the server-side <script> blocks with the non-default
scripting language cannot call function in server-side <script> blocks with the
default scripting language because these server-side <script> blocks have not
been interpreted and the ASP engine cannot switch the work scripting language
immediately. During interpretation, any response output will be responsed to the
ASP response buffer by the ASP engine immediately.
Similarly, may be these proceduces can be used to repeat with another type of
non-default scripting language when there are other server-side <script> blocks
with other different types of non-default scripting language by switching the
working script language of the ASP engine to the same type of non-default
scripting language. However this scenario is not tested,
After the completion of check, reformat, and interpretation of all server-side
<script> blocks with non-default scripting language, the ASP engine begins to
response the static HTML codes and the client-side scripts in the cached
intermediate page to the ASP response buffer directly and to response the
results of all ASP code blocks in the cached intermediate page after
interpretation following the sequance codes in the cached intermediate page. All
coding errors in the ASP code blocks with the default scripting language can be
detected accordingly. Therefore the results of the all ASP code blocks can also
be inserted to the static HTML codes accordingly.
Besides, both the ASP code blocks and the server-side <script> blocks with
default scripting language can call functions in server-side <script> blocks
with the same default scripting language because these functions can be
interpreted immediately whenever necessary and call functions in server-side
<script> blocks with the non-default scripting language because these functions
have already been interpred before. However, unlike the server-side <script>
blocks with the non-default scripting language, only the related code block of
the called function in the server-side <script> blocks with the default
scripting language will be interpreted and the other unrelated codes of the
server-side <script> blocks will not be interpreted.
After the completion of interpretation of all ASP code blocks with default scripting
language, the ASP engine begins to interpret the server-side <script> blocks
with the default scripting language. Similarly, during interpretation, any
response output will be responsed to the ASP response buffer by the ASP engine
immediately.
Because of the unexpected sequence of processing the <SCRIPT> element due to the
complexity of the script arranged by the ASP engine, the ASP page mixed with
server-side <SCRIPT> blocks and ASP code blocks within delimiters <% ... %>,
might be not processed as the about mention sequence, therefore the <SCRIPT>
element is usually used for containing procedures and functions only. Besides,
the client-side script will be interpreted on the browser according to the
sequence of the HTML code.