Introduction to Active Server Pages
 
SEARCH: webmonkey  the web

 
ASP
-------------------------
Print
this article for free. 
-------------------------

Pages:
1  Introduction to Active Server Pages
2 ASP Syntax
3 Browser Detection

Introduction to Active Server Pages
by Kevin Cooke 30 Sep 1998

Kevin Cooke [an error occurred while processing this directive]is Director of Engineering at Wired Digital. He has a life-sized replica of an alien that he'd like to sell you.

Page 1

Server-side programming used to be pretty difficult. Making something work via CGI required some knowledge of arcane programming languages like Perl or C. To boot, it was inefficient. Each time someone hit a CGI script, a new process was created on the server; if your script was written in an interpreted language like Perl, the server had to start up another Perl interpreter, taking up processing time and memory. The situation got even hairier when it lived on a site that was getting a few thousand hits a day.

Also, you couldn't program in any of the nifty development interfaces, like Visual Basic or Visual C++ or Visual Anything. You were limited to watching it crash and burn, then checking out the server logs. This experience was good practice for catching stupid syntax errors, but I have since learned that I have better things to do with my life, like read Wired News.

Microsoft attempted to change all this when they introduced Active Server Pages. ASPs are server-generated pages which can call other programs to do things like access databases, serve different pages to different browsers - basically, anything we used to do with CGI. ASP is almost as efficient as writing code directly to the server's application program interface, and it's a lot more efficient than CGI because it runs as a service and can take advantage of multithreaded architectures.

Here's the official word from the Microsoft site: "Active Server Pages is an open, compile-free application environment in which you can combine HTML, scripts, and reusable ActiveX server components to create dynamic and powerful Web-based business solutions. Active Server Pages enables server-side scripting for IIS with native support for both VBScript and Jscript."

Sounds great, right? But keep in mind that ASP is not a cure for cancer. True, it might heal what ails you if you're an old-school Microsoft developer who's comfortable staying in Monopoly Land. IMNSHO, ASP was introduced so that all the Visual Basic programmers in the world would feel needed again, now that the Web had shoved Unix geeks back into the limelight (they tried and failed with VBScript, which pretty much died for a whole host of reasons).

ASP stuck around, though, because it made sense. It evolved into an "open technology framework," meaning you didn't have to use Microsoft products to create code in it, though that's still the best way to go, honestly. Nowadays, you can create ASP pages using whatever language you want, but VBScript is still the most common choice. It seems likely that more people will choose to use ASP - we do on HotBot - because all of those MS developer tools are actually pretty good and written to save you time. ASPs can also take advantage of COM and DCOM (Component Object Model and Distributed Component Object Model) objects with minimum effort.

I'll be using VBScript in my examples, but you can use JScript (JavaScript or ECMAScript or whatever) out of the box, too. Also, one company sells an out-of-the-box Perl solution for ASP, and Java is pretty easy to use with ASP, too. I'll also assume that you're using IIS 4.0 on Windows NT, even though another company has ported it to other servers and platforms. Like HTML and Perl, you can use any text editor to create ASP code. Microsoft VisualInterDev will give you nice highlights and wizards and pop-up boxes, but you may not need all that stuff. Personally, I still use vi a lot.

All set? Then let's take a look at the code.

next page»