Академический Документы
Профессиональный Документы
Культура Документы
Introduction:
Active Server Pages (ASP) is one of the most exciting and interesting Internet
technologies ever created by Microsoft. ASP is a program that runs inside IIS (Internet
Information Services). With ASP, developers can build dynamic websites very easily. A
script running on the server receives a request from the client and generates a customized
HTML page, which will be returned to the client. ASP is available with Microsoft IIS
(Internet Information Server). It is available only with the Windows NT operating system.
If you are using Windows 98 or 2000, you can use Microsoft Personal Web Server to test
your ASP scripts.
ASP is a feature of the Microsoft Internet Information Server (IIS), but, since the
server-side script is just building a regular HTML page, it can be delivered to almost any
browser. You can create an ASP file by including a script written in VBScript or JScript in
an HTML file or by using ActiveX Data Objects (ADOs) program statements in the
HTML file. You name the HTML file with the ".asp" file suffix. Microsoft recommends
the use of the server-side ASP rather than a client-side script, where there is actually a
choice, because the server-side script will result in an easily displayable HTML page.
Client-side scripts (for example, with JavaScript) may not work as intended on older
browsers.
When you type a URL in the Address box or click a link on a Web page, you're
asking a Web server on a computer somewhere to send a file to the Web browser
(sometimes called a "client") on your computer. If that file is a normal HTML file, it
looks exactly the same when your Web browser receives it as it did before the Web server
sent it. After receiving the file, your Web browser displays its contents as a combination
of text, images, and sounds. To sum up
• 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"
Definition:
Active Server Pages (ASPs) are Web pages that contain server-side scripts in
addition to the usual mixture of text and HTML (Hypertext Markup Language) tags.
Server-side scripts are special commands you put in Web pages that are processed before
the pages are sent from your Personal Web Server to the Web browser of someone who's
visiting your Web site.
An Active Server Page (ASP) is an HTML page that includes one or more scripts
(small embedded programs) that are processed on a Microsoft Web server before the page
is sent to the user. An ASP is somewhat similar to a server-side include or a common
gateway interface (CGI) application in that all involve programs that run on the server,
usually tailoring a page for the user.
ASP Compatibility:
• 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
With conventional static HTML, the user types in a Web address and the browser
sends a request for the Web page to a Web server. The Web server receives the request
and retrieves the appropriate HTML file from a disk or memory and transmits it back to
the browser. The user's Web browser translates the HTML file and the results are
displayed in the browser window. The results are static as long as the underlying HTML
page is unchanged. Static Web pages are used when information is not expected to
change much over time. Static Web pages are ideal for home pages or sites where content
is not going to be modified frequently. In order to make changes to static Web pages, one
must edit the HTML file.
ASP and conventional HTML work in almost the same way. One major difference
between ASP and conventional HTML is that ASP is dynamic. This is because with ASP,
scripting code runs on the server and produces HTML output, which is then sent to the
browser for display.
When a browser requests an ASP file from the Web server, the ASP
interpreter reads through the ASP file, executes any of the ASP commands contained
within and sends the resulting HTML to the browser. This means that the same ASP page
might produce HTML that appears in the browser differently each time it is requested. An
ASP file can contain any combination of HTML and script. Since ASP pages produce
standard HTML, they require no specific browser. Finally
• 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
1. Server receives the request for the ASP Page from the client
2. Server loads the ASP Page and executes the Script and HTML in the page.
3. A new HTML page is generated
4. It is then returned to the user and viewed in the browser.
Since pure HTML is generated, it obviously works on browsers such as Internet Explorer
and Netscape.
<html>
<body> My name is: Donald Duck
<%
dim name
name="Donald Duck"
response.write("My name is: " & name)
%>
</body>
</html>
ASP Procedures :
The ASP source code can contain procedures and functions:
<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>
<p>Result: <%call vbproc(3,4)%></p>
</body>
</html>
To save the file:
Save the file as Example 1.1 in the <a href="file:///C:/Inetpub/wwwroot">
C:Inetpubwwwroot</a> directory.
You should save all your ASP files in this directory so that the server can be able
to locate the files and execute them.
Running an ASP Page:
Now, it's time to fire up your Web browser to view the output. Open your browser
and type
<a href="http://localhost/Example1.1.asp">http://localhost/Example1.1.asp</a>
in the address bar
ASP Objects:
Active Server Pages consist of six built in objects. They are ready made objects which
provide functionality to your web pages without requiring you to make custom objects.
Following are the six built in ASP objects:
• Application
• ASPError
• ObjectContext
• Request & Response
• Server
• Session
Application Object:
The Application object is created when the first .asp page is requested after
starting the IIS and remains there until the server shuts down. All the variables created
with application object have application level scope meaning there by that they are
accessible to all the users.
Error Object:
The ASPError object is created when Server.GetLastError is called. It contains a
lot of info about the last scripting error found in the page.
Object Context:
The ObjectContext object is used to commit or abort transactions.
Request Object:
The Request object makes available all the values that client browser passes to the
server during an HTTP request. It includes client browser info, cookie details ( of this
domain only ), client certificates ( if accessing through SSL ) etc.
Response Object:
The Response object is used to send the output back to the client (browser). It
includes all the HTTP variables, cookies that will be stored on the client browser and
other info about the content being sent.
Server Object
The Server object makes us available the methods and properties of our server ( IIS ).
Session Object
The Session object is automatically created every time client browser access
pages from your web site. Session object is specific for every user and varies from user to
user. It can be used to store variables specific for a user and IIS will maintain these
variables when the client moves across pages within your site.
Advantages & Disadvantages of ASP:
ASP is a server side script and it can perform many backend processing jobs for a
web site, same way it can't do many things particularly the client end operations as it has
no control over the client end events or user controls. So there are many advantages and
disadvantages of using ASP to manage web pages.
Using server side scripting language like ASP we can manage the content of any
page and such dynamic code (or content) for the web browsers can be generated based on
various conditions we set in our ASP program. To a visitor the back end script or
processing is of no use. They are more interested in design, content, speed etc. So there is
no point in asking ASP engine to work when there is simple html content to be displayed
at browser end. This will also improve the loading speed of the page. The user browser
does not understand scripts we run at server. Brower understands JavaScript (if enabled),
html, CSS etc. So what ever output we want to be send to the browser has to be written
using these languages. So the task we want to be performed at client end can't be written
at server end using ASP.
ASP engine finishes its job of processing the code and then send the codes to
users browser. From this point on words till again the page request comes back to server,
there is no control of ASP on the page. So we should not expect ASP to perform some
tasks which are likely to happen at the client browser end. This will be clear when we
discuss some of the task and where ( client or server side ) the task is to be completed and
which script will take care of it.
References:
1. http://www.plus2net.com/asp-tutorial/ASP_Introduction.php
2. http://www.w3schools.com/asp/asp_install.asp
3. http://www.asptutorial.info/
4. www.asp101.com/
5. http://www.stardeveloper.com/articles/display.html?article=2000030902&page=2