Your first ASP page
ASP pages (Active Server Pages page sounds a bit melodramatic but its easier to refer to them like this) are nothing but web pages. The difference is that they have an extension .ASP and you write the code in a Server Side Scripting language.
Do we know what’s Server Side Scripting? This doesn’t actually matter if we delve into such nitty-gritty, but let’s sound a bit philosophically intellectual. Now, there are two sorts of scripting languages:
Server Side (the hosting server where all the pages and programs reside)
Client Side (the web surfer using the browser – actually the browser is the client)
No, we are not talking about some corporate politics with all this “siding” talk. Ok, before I begin with my bad sense of humor, “Client Side Scripting” is what we generally see when we code basic Java Scripts in our web pages to validate HTML forms or implementing those cool image rollover effects or opening custom popup windows etc. When you view the source of an HTML page, and if the Java Script has been written in the page itself (they have external Java Scripts too, but then that’s a different story), then you can see the script with all it’s gory details. A simple example of a Client Side Script written in Java Script is:
alert(“Welcome to the Incredible world of Amrit Hallan!!”);
And then you can use it when the page loads:
<body onload=”welcome();”> </body>
A Server Side Script, on the other hand, does not manifest itself when you try to use the “View Source” option of your browser. It is a server side matter so unless you have the actual access to the server, you cannot view the portion containing the server side coding. But yes, the rest of the HTML matter is visible.
A typical ASP page looks like
<% Option Explicit %>
SayThis = “Finally, I’m learning ASP!”
ASP wrap up
Provided you’ve configured your PWS in an amicable manner, this docile file should show up without fuss. You can copy/paste this page as it is using your preferred editor, and save the file as “basic.asp”.
As you know, a basic HTML web page begins with the tag, when you begin to work with an ASP page, try to make the first line as:
<% Option Explicit %>
The first line tells the concerned authorities that the following code is going to contain VBScript syntax.
The second line forces us to declare every variable before we use it. We’ll come back to this later when we are in a more aware state of mind.
My preferred script for ASP is VBScript, so most of my ponderings will be in this language. A few daredevils write their ASP pages in Perl too, but personally I feel it is an overkill and they are just trying to either show off or the features they want to use only exist in Perl. For that matter, even C++ is used for making ASP pages.
Anyway, done with the first line, are we?
As you can observe, we have all the quintessential HTML tags in an ASP page too, but they are only necessary if you intend to display the page to your visitors. If the page just includes a script that performs some programming function and then loads some other page, you can simply have the pure ASP code with first line as <% and the last line is %>.