An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are executed on the server
What is ASP?
- ASP stands for Active Server Pages
- ASP is a program that runs inside IIS
- IIS stands for Internet Information Services
- IIS comes as a free component with Windows 2000
- IIS is also a part of the Windows NT 4.0 Option Pack
- The Option Pack can be downloaded from Microsoft
- PWS is a smaller - but fully functional - version of IIS
- PWS can be found on your Windows 95/98 CD
- ASP is a Microsoft Technology
- To run IIS you must have Windows NT 4.0 or later
- To run PWS you must have Windows 95 or later
- ChiliASP is a technology that runs ASP without Windows OS
- InstantASP is another technology that runs ASP without Windows
What is an ASP File?
- An ASP file is just the same as an HTML file
- An ASP file can contain text, HTML, XML, and scripts
- Scripts in an ASP file are executed on the server
- An ASP file has the file extension ".asp"
How Does ASP Differ from HTML?
- When a browser requests an HTML file, the server returns the file
- When a browser requests an ASP file, IIS passes the request to the ASP
engine. The ASP engine reads the ASP file, line by line, and executes the scripts in the file. Finally, the ASP file is returned to the browser as plain HTML
What can ASP do for you?
- Dynamically edit, change or add any content of a Web page
- Respond to user queries or data submitted from HTML forms
- Access any data or databases and return the results to a browser
- Customize a Web page to make it more
useful for individual users
- The advantages of using ASP instead of CGI and Perl, are those of simplicity
- Provide security since your ASP code can not be viewed from the browser
- Clever ASP programming can minimize the network traffic
Important: Because the scripts are executed on the server,
the browser that displays the ASP file does not need to support scripting at
Write Output to a Browser
You can use several scripting languages in ASP. However, the default scripting language is VBScript.
Other Scripting Languages
response.write("My name is: " & name)
famname(0) = "Jan Egil"
famname(1) = "Tove"
famname(2) = "Hege"
famname(3) = "Stale"
For i = 0 to 3
response.write(famname(i) & "<br />")
Looping Through Headers
for i=1 to 6
response.write("<h" & i & ">Header " & i & "</h" & i & ">")
Time based message (VBScript)
response.write("<p>" & now())
response.write(" (Norwegian Time) </p>")
If h<12 then
7/13/2007 8:50:36 AM (Norwegian Time)
Time based message (JScript)
var d=new Date()
Response.Write(d + " (Norwegian Time)")
Fri Jul 13 09:35:10 EDT 2007 (Norwegian Time)
Lifetime of Variables
A variable declared outside a procedure can be accessed and changed by any
script in the ASP file.
A variable declared inside a procedure is created and destroyed every time
the procedure is executed. No scripts outside the procedure can access
or change the variable.
To declare variables accessible to more than one ASP file, declare them as session
or application variables.
Session variables are used to store information about ONE single
user, and are available to all pages in one application. Typically information
stored in session variables are name, id, and preferences.
Application variables are also available to all pages in one application.
Application variables are used to store information about ALL users in a