When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Friday, September 08, 2000

Getting Started with ASP

By Akshay Luther


Welcome to the wonderful and exciting world of ASP. This article is focussed on passing on knowledge and information that I have had to acquire the hard way in a nice compact high-powered package. For more beginner-level ASP information, also be sure to check out the Beginner ASP FAQs on 4Guys.

- continued -

'

Skip the next few paragraphs if you already know what ASP and are familiar with the client/server model for web applications.

Well, what is it? ASP is a server-side Microsoft technology that provides an environment for Server Side programming. It lets you use either Jscript (Microsoft's version of JavaScript) or more commonly VBScript to write scripts that execute on the server. So why is it so cool? Primarily, because it lets you create HTML on-the-fly. It lets you do this based on, for starters, two very important sources of data: user input and in conjunction with Microsoft Active Data Objects (ADO) information pulled from a database (as well as others, which you'll discover as you go along). Additionally, you can use ActiveX components in your ASP pages! The huge bonus with this is that if some functionality doesn't exist in the provided installable components, you can just write your own using a compiler that can compile as a .dll! Using components makes sites more robust and scaleable and very importantly goes a long way in separating the presentation layer from the business logic layer in the context of the 3-tier model. More on that later...

Thus very powerful web applications can be built by combining scripts built with ASP that communicate with databases and use ActiveX components. An e-commerce storefront is a classic example. Now if all that didn't get you excited to the point of jumping out of your seat ... maybe you should consider a change in profession! Anyhow, simply put, ASP lets you create pages that are created dynamically, as opposed to static pages that are always the same.

As an example, an ASP called TodaysGuide.asp in a radio station's website is to display a list of programs that are on for a particular day. Information about each program is stored in a database table containing the following fields: day_of_the_week, time_slot, name, description, rating etc. When the page is called via a browser e.g. http://www.radiostation.com/todaysguide.asp, the ASP checks what day of the week it is, pulls the relavant data from the database, formats and displays it. Thus a different page is generated on every day of the week that the page is accessed. This is a very simple example, and as I mentioned previously, complex applications can be created when multiple scripts are used together.

To understand how it works, you need to know a little about the 'client/server model' and how web programming languages relate to it. On the Internet, when you visit a website, you are the 'client' and the computer that the website resides on is the 'server'. When you type in a URL in your browser, you, the client 'requests' a page and the server 'serves' it up to you. Becase ASP is a server-side technology, the page is executed on the server and the HTML is created in real-time and then served to the client. So when you try to look at the source by choosing [view]->[source] on your browser, you don't see the ASP code; rather you see the HTML generated by the ASP code. Client-side languages such as JavaScript, on the other hand, are executed on the client. So, when a page that contains JavaScript is requested, the page is downloaded in its raw form and the code is executed on the client. Of course it is entirely possible and in many cases convenient to have ASP and JavaScript on the same page. All you have to remember is that the ASP will be executed first and then the JavaScript. (For more information to help understand the client/server model, be sure to read: ASP Basics: What's Happening Back There?)

What makes Active Server Pages convenient is the fact that they are essentially HTML pages with embedded ASP code. So an ASP contains HTML which is static as well as ASP tags which delimit ASP code. It is the code contained within the ASP tags that act on data, communicate with databases, generate HTML dynamically, use ActiveX objects etc.

Now that you know what it is and how it works, you get to learn how to make it work. The rest of the article attempts to get you started on just that. The first decision you will have to make is the language you are going to code in: you have the choice of VBScript and JScript. With additional support you can code in other languages as well, but we'll restrict our discussion to these two. VBScript is the more popular of the two for ASP. Its syntax is a little easier to use and most of the available books and tutorials use VBScript. I recommend you use VBScript for this reason. I started coding ASP in JScript simply because I was much more comfortable with its syntax and the last time I had coded in any version of BASIC was in 9th Grade. I later switched for the reason I recommend VBS even though it meant investing some time getting familiar with the new syntax. So you'd need some major motivation to use JScript! (For more information on choosing a language for ASP, be sure to read: ASP's Server-Side Languages!)

SOFTWARE
Before you can start writing your own scripts, you need to set up an environment where you can execute your scripts. If you have an NT Server setup that's not a problem, but chances are that you are running Win98 in which case you'll have to install Personal Web Server (PWS). Find it in the add-ons directory on the Win98 CD. Make sure you enable the option to install 'Microsoft Data Access Components 1.5'.

You'll also need to install some database software. Commercial sites use databases such as Oracle or Microsoft SQL Server, but for small-scale development you can use MS Access. Access 97 will do fine.

Lastly, you need an ASP editor. Yes, Microsoft again! Visual InterDev this time. Install it as an option as part of Visual Studio. You can also use Allaire HomeSite 4.5 just as well to start with - it's the most awesome non-WYSIWYG HTML editor around and has basic support for ASP. If you can't get hold of either you can use your favourie text editor, such as Notepad (if you can live with your code not being nicely coloured!).

In Part 2 we'll look at where to get some great ASP information on and off-line!

  • Read Part 2!



  • ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article