Active Server Pages is a server-side scripting technology that allows for session and application layer interactivity. The code is most commonly written in vbscript, which is based on visual basic, but can also be written in jscript, ecmascript or perlscript. It is made by Microsoft, and is a standard part of the IIS server and it's enhancements, including the Enterprise Server and SQL Server.
ASP is an object-oriented language. The core built in objects are:
- Request object, which provides access to information about or passed with the HTTP request, including cookies and form entries.
- Response object, which allows for the passing of data over http. This makes tasks such as redirection simple, and allows for direct output from the code.
- Session, which allows for data to be retained throughout a session easily.
- Application, which allows data to be passed between sessions or for actions to take place independent of user input.
- Server, which allows for interaction with the file structure and services available on the server.
Other services will add other objects to the list, but these are the ones you'll refer to all the time for routine scripting.
Being a Microsoft product, ASP runs on Windows NT and Windows 2000 running IIS, however, some third party software now makes it possible to run it under other OSs.
One of ASPs big advantages is that it can be written inline with your HTML code. Any page with the '.asp' extension will be run through the ASP engine. HTML will be passed and ASP will be executed. To denote ASP code in your HTML file, you must enclose it in greater than/less than signs and percent signs, like this:
<% This is my ASP code %>
Since the code is run real time as the HTML is being passed, you can automate a lot of conditional output situations very easily:
<% If (variable1 = condition1) Then %>Output 1
<% Else %>Output 1<% End If %>
ASP code can also be invoked using this syntax:
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
This is my ASP code
Another useful feature of ASP is the global.asa file. When this file
is in the root directory
of a web site
, you can write function
s that will execute automatically whenever the application
is started or terminated and whenever a session
is started or terminated. This makes such things as keeping usage statistics or managing shopping carts very simple.