About Website Source / Network

 

Website Hosting Guides - Using ASP

Tutorials

ASP – Active Server Pages Overview

On this page:

Active Server Pages (ASP)

Ever thought of building a framework for dynamic HTML pages? Or making Internet and Intranet based applications interactive? It is possible, and the best part is that you need not rack your brains anymore. Just get your hands on ASP - an abbreviation for the Active Sever Pages, a specification for a dynamically created Web page with an .ASP extension. ASP is also a feature that installs with Microsoft's Internet Information Services (IIS) web-server and require no special interaction or configuration. The server-side technology also doesn’t put any requirements on the client or browser, and, as a result, gives rise to no browser-compatibility issues. An ASP file can contain text, HTML tags and scripts that are executed on the server; therefore, some basic understanding on HTML / XHTML shall be an added privilege.

Active Server Pages

ASP Quick Facts

An abbreviation for Active Server Pages and a program that runs inside Internet Information Services, a free component that comes with Windows 2000 or with Windows NT 4.0 Option Pack.

ASP is a Microsoft Technology and a feature of Microsoft's web server software.

Instant ASP and ChiliASP are the technologies that allow ASP to run without Windows OS.

An ASP file is similar to a HTML file and 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".

All Microsoft Hosting packages support Active Server Pages.

ASP comes free since it comes with the Win2000 OS. It is part of IIS and must be added with add/remove programs through the menu.

What is ASP?

General Description: Active server pages are defined as a server-side scripting technology that combines HTML, scripting, and components for creating and running dynamic, interactive content and powerful web-based applications. ASP can interact with databases and can integrate database content with the pages it generates. The process involves generation of dynamic HTML and passing it to the browser, which displays it to the user. Thus, creating dynamic Web sites in a Windows environment becomes an easy task with ASP.

Definition:

ASP is a type of Web page containing server-side scripts. A server side script is a special command that is processed before the page is sent from the server to a web-browser. Usual text and HTML tags can also be a part of that web page and doesn’t hamper the performance of ASP. A normal HTML file looks the same as it was made when a web-browser receives. Active Server Page involves a similar process, but with an extra processing step. The extra processing takes place just before the server sends the file.

What to achieve with ASP?

ASP does a lot more than normal HTML; an adept user can:

  • Edit, modify and add extra content to a Web page in a dynamic way.
  • Respond to user queries.
  • Submit data from plain HTML forms.
  • Make ASP access any data or databases and return the results to a browser.
  • Customize a Web page.
  • Enhance security since ASP code does not respond to View: Source.

Server-Side Scripts

These scripts begin with <% and end with %> and are called opening tags and closing tags respectively. The tags contain the server-side scripts and can be inserted anywhere in a web page including the HTML tags.

ASP: Why and when?

Active Server Pages (ASP) found strong grounds in business and software development. From applications that suit well with ASP to applications built with ASP in mind, the strength of ASP lies in building dynamic HTML web pages based on a user's input and profile.

There are a few guidelines regarding using ASP, the first one being a decision regarding sticking to it and not wandering off to UNIX or some other server platform. ASP excels with ActiveX/COM components, SQL Server databases, Microsoft Index Server and Microsoft Commerce server. ASP also uses VB Script as a language, so ASP performs well in the hands of an experienced VB user. And just like any other programming language, troubleshooting is required for ASP.

Other factors that compel ASP to be used:

The ASP Programming Interface

Another major factor that makes ASP the programmer’s choice is its interface to common tasks; the feature simplifies web programming by turning the simple tasks simpler. The interface implements the features of ASP besides exposing them as objects.

The ASP Intrinsic Objects

While in object-oriented programming, the programmer creates an instance of an object, ASP delivers objects that are already instantiated and available to the scripting language engine. The objects are thus called intrinsic and involve no work in advance. These objects can also be accessed any time and encapsulate a set of very specific services, apart from providing shorthand access to common tasks like reading the submitted data, reading and writing cookies, redirecting the client's browser and some extended functionality.

Application Objects

These can be described as placeholders for server side global variables (IIS application), which define the physical space of a web server allotted for a website. But a web server may have multiple IIS application, whereas one ASP application object is allotted per IIS application. This is due to the Application object’s collection that contains user created variables. So whenever a programmer creates a variable, it is put on the contents collection, which can store scalar variables and arrays apart from the objects as well.

How ASP works:

Contrary to familiar document types like HTML documents, ASP serves documents of its own file type. Thus, an ASP document allows processing on the server side before it is returned to the browser. It had already been mentioned before that an ASP document bears the file extension .asp. Documents with such an extension provide the existing features derived from ASP; it is also capable of executing script commands within the document. The file extension helps the web server recognize the file, which executes the script commands within the file. The process; however, treats other markup languages (e.g. HTML) in a standard fashion. This makes the source code of the saved file's PerlScript (script commands written in PERL) unavailable to the user since view: source doesn’t work in this case, the reason being everything is processed on the server side and returned items come in a standard format like HTML.

N.B. Object-oriented programming in Perl comes handy to understand ASP; Perl documentation on object-oriented programming is thus recommended for obtaining a basic understanding of the aspects of an object and its origin.

Programming with ASP: The Guidelines

For executing the script commands within an ASP file, it must be specified what scripting language should be used for ASP to interpret the commands. Setting a default scripting language within the .asp document can do this; the specified scripting language shall then execute all script commands within the symbols <% and %>, also known as the script-delimiters. This setting can either be applied within the Microsoft Management Console's IIS snap-in, or can be used as what ASP recognizes as a page command (indicated by @, the special directive). Below is provided the codes for setting the default scripting language for the ASP file to PerlScript:

    <%@ Language=PerlScript %>
    <%
    for($i=0; $i<=10; $i++) {
    #
    # Perl code
    #
    }
    %>

    There’s an alternative way for setting the scripting language: <SCRIPT Language=PerlScript RUNAT=Server> and </SCRIPT>, the delimiters are a must for a defined scope. This results in the execution of the code within the <script> elements. However, the default scripting language, in this case, becomes void. E.g.


    <SCRIPT Language=PerlScript RUNAT=Server>
    for($i=0; $i<=10; $i++) {
    #
    # Perl code
    #
    }
    </SCRIPT>

    Writing Programs with ASP: Few Examples to provide an idea

    <HTML>
    <HEAD>
    <TITLE>Testing with ASP</TITLE>
    </HEAD>
    <BODY>
    <%
    Response.Write “Testing with ASP”
    %>
    </BODY>
    </HTML>

    There’s a single line of VBScript within the opening and closing tags that starts with Response.Write. Upon execution, the statement displays the string “Testing with ASP” on the web page.

    For Displaying the Date in a Web Page:

    <HTML>
    <HEAD>
    <TITLE> Testing with ASP </TITLE>
    </HEAD>
    <BODY>
    <%= Date %>
    </BODY>
    </HTML>

    “Date” is a function here that shall provide the current date. If it was “Time”, the page would return the time. And if it was “Now”, the command would have displayed both date and time.

    For example,

    <HTML>
    <HEAD>
    <TITLE> Testing with ASP </TITLE>
    </HEAD>
    <BODY>
    <%
    Response.Write Now
    %>
    </BODY>
    </HTML>

    Individual elements like Year, Date, Month, Hour, and Minute & Second can be displayed by using the functions:

    <HTML>
    <HEAD>
    <TITLE> Testing with ASP </TITLE>
    </HEAD>
    <BODY>
    <%
    Response.Write “Year: ” & Year (Now)
    Response.Write “Month: ” & Month (Now)
    Response.Write “MonthName: ” & MonthName (Month(Now))
    Response.Write “Hour: ” & Hour (Now)
    Response.Write “Minute: ” & Minute (Now)
    Response.Write “Second: ” & Second (Now)
    %>
    </BODY>
    </HTML>

     

     

Note: All Content Copyright © Website Source, Inc.

Footer Image



Login


Website hosting customer feedback

I have been a customer for only a month but I am constantly amazed at how responsive your technical support team is. Keep up the great work!

Omar
read more