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.