Home ASP/VBScript HTML Resources Graphics


Active
Server
Pages

Click here for the expanded menu Getting
Started


Also See:
Introduction
Samples
Components
ASP Links

Active Server Pages Ready, Set...Go!
First of all, you will need a server to run your ASP scripts. If you are running Windows 98, the Personal Web Server is included on the CD. If you're not sure if you have installed PWS, check in Control Panel -> Add & Remove Programs -> Windows Setup -> Internet Tools. If The box next to Personal Web Server is checked, you're in business! If not, click on the box, and click OK. Be sure to have your Windows 98 CD handy, as you'll probably need it to complete the install process.

If you are running Windows 95 or NT 4, download NT Option Pack 4, which is free to download and use. Win95 users: don't let the name fool you - you'll have the option of specifying Win95 during the download process. Once its downloaded (its a BIG file!), install it following the directions provided by the install routine - its a painless process.  

  Top of Page

Your First Script
ASP is usually written using Visual Basic, Scripting Edition (VBScript) or JScript. I use VBScript, as I have a background in programming with BASIC, and the jump to VBScript was relatively painless, despite having been away from BASIC programming for quite some time. The examples here are all done in VBScript.

Open up a text editor - Notepad or any other plain text editor will do. A text-based HTML editor will also work (I do most of my scripting with Homesite). We'll start out with a very simple script... a take-off on the old "Hello World" script.

We'll begin by writing a bit of standard html. This sets up the html page that the script will write to. Then, we'll put in a bit of vbscript, which is enclosed by
<% and %>, to write to the page and generate today's date. We'll then end the script with standard HTML.

<html> <head> <title>My First ASP script</title> </head> <body> <font face="arial" size=4> <% Dim Today ' declares Today as a variable Today = Date() ' makes Today's value today's date Response.Write "Hello, ASP World!" Response.write "<br>My first script was created " response.Write(Today) ' now we'll end the response response.end %> </font> </center> </body> </html>

Let's analyse the script portion briefly. First you see the Dim statement. While it is generally considered good form to declare your variable names with a Dim statement, it isn't required. Now that I have declared my variable, I next give it a value. Date() returns today's date.

Next, I want the script to write to the page, so I use response.write in the next three lines. The first two lines of the response writes text to the screen - when doing this, always remember to enclose the text string in double quotes. You'll note that I've included an HTML tag in the response just as long as its within the double quotes. The third response line returns the value of Today. Note that since VBScript is not case sensitive, I can get away with capitalizing "response.write" differently in all three lines.

The next line, the one that begins with a single quote, is a comment. Comments are extremely handy - adding comments to your scripts not only helps you remember exactly what you were trying to accomplish with a particular part of the script, but also helps others who see your script to understand your logic.

The final line ends the response. If you have no further scripting on the page, you can omit this. I use the response.end statement generally when I'm using a conditional statement (if then...else) and want to go no further if certain conditions are met.

  Top of Page

Running Your Script
In order to be able to run your ASP scripts, you must first save the script ,using the .ASP extension, to a directory within your wwwroot. The standard path for NT Option Pack is c:\inetpub\wwwroot and for Win98 PWS (and older win95 versions of PWS if I recall correctly) its c:\webshare\wwwroot.

You must also properly configure the directory in which you save your ASP scripts. The directory must allow scripts access, and generally its a good idea to turn off read access in that directory for security reasons. To check this, fire up your web server administration screen and right-click on your scripts directory.

Now its time to see your script in action. Run your favorite browser, and point it to http://localhost/script_directory_name/script_name.asp, where script_directory_name is the actual name of the directory containing your script and script_name.asp is the name of your script. Now you should see your first effort come to life. Congratulations - you have just run your first script!

  Top of Page

Setting Up a DSN
If you plan to use ASP to access a database, you will want to set up a DSN (Data Source Name) for each database you'll use. If you plan to try out some of the sample database scripts from this site, you will need to set this up before trying any of the scripts.

Setting up the DSN is a simple process. Simply double-click the ODBC applet in the Control Panel, choose the System DSN tab, and click Add. Choose the type of database you'll be working with - the sample database from this site is MS Access - then click finish. You'll then need to type in the database name in the Data Source Name box, and click Select. Next you'll navigate to the drive and directory where the database is located, click on the file name and click OK on that window and the one behind it. Now you can refer to the database by name in your scripts and the system will know which ODBC driver to use and where the database is located.

  Top of Page

Neat, But...What Now?
You have just sampled a tiny part of what ASP is all about. But, what else can ASP do? Lots of things! You can use it for browser detection, server variables such as what IP and referring page a site's user comes from, reading and writing to a database or text file, surveys and quizzes, electronic commerce, chat, message boards...and much more. With add-on server components, you can email web form responses, upload and download files, rotate banners - the possibilities are endless.

Interested in learning more? See the Script Samples and ASP Links and Resources pages for sample scripts, sites, documentation, tutorials and classes. If you're looking for good books on ASP, I recommend Beginning Active Server Pages 2.0 and the "bible" of ASP programming - Professional Active Server Pages 2.0, both published by Wrox Press.

  Top of Page   Samples Page








© 1998, 1999 Kathi O'Shea