Choosing a Server Model

You know already that there are several common server-side languages. This begs the question (often asked by those new to dynamic site development), "which server model should I use?" The following list summarizes the main functions, pros, and cons of each:

Active Server Pages (ASP): ASP is a Microsoft technology that ties together its IIS (Internet Information Services for Windows 2000 and XP) or PWS (Personal Web Server for Windows 98) servers with VBScript (Visual Basic Script) for dynamic Web site development. (You can also use Microsoft's implementation of JavaScript, JScript.) ASP is free and built into all IIS and PWS servers, which means that virtually all Windows users can develop ASP sites for free with little configuration. Its code, VBScript, can be somewhat daunting for those with little to no programming experience. ASP is currently being replaced with Microsoft's much-ballyhooed ASP.NET (see below).

ColdFusion: ColdFusion is Macromedia's server technology. Its tag-based syntax is generally much easier to use than VBScript, and it certainly requires fewer lines of code. Most designers find it the most accessible of all the server models. Newbies aside, ColdFusion is a powerful language that makes dynamic site development rapid. The disadvantage to ColdFusion is that it is not free, though the boost to productivity it affords usually means it pays for itself.

PHP Hypertext Processor (PHP): An acronym within an acronym, PHP is a fast-growing server model for a variety of reasons. As an open-source solution, it is free and ties in well with other excellent open-source products, including the Apache Web server and MySQL database management system. Its code is comparable in difficulty to that of ASP. One disadvantageand this is true of many open-source productsis that setting up and configuring PHP-Apache-MySQL can be difficult.

ASP.NET: The Web authoring portion of the .NET phenomenon, ASP.NET is a powerful new technology that holds a lot of promise for rapid, powerful Web development. Like its predecessor ASP, it runs on any Microsoft IIS server that has the free .NET extensions installed. But ASP.NET is conceptually different from ASP, ColdFusion, and PHP. ASP.NET meets the needs of desktop application programmers, in some ways at the expense of traditional Web programmers. Whether you know only HTML, or you have experience with JavaScript or even ASP, you will need to do some adjusting to work with ASP.NET effectively.

JSP: JSP is the Java-based solution to dynamic Web site development, requiring a Java server (such as a J2EE server) to interpret the code. JSP is fast, providing impressive response times. But its code, once again, is daunting for those new to dynamic Web site development.

This book provides coverage of ASP and ColdFusion. However, this is not an ASP or ColdFusion book. The book is designed to initiate readers into the concepts and practices of building dynamic Web sites using Macromedia Dreamweaver MX. You will learn lots of code and coding concepts along the way, and you will also make use of Dreamweaver's server behaviors to speed up and simplify development. When you are done, you will have a solid sense of what's possible, how several different technologies merge to create dynamic pages, and how to plan and build sites that use these technologies effectively. Most likely, you will not in the end be an ASP or ColdFusion expert per se, but you should be able to get an ASP or ColdFusion book at that point and understand it well enough to push forward and develop ambitious Web projects.

Having summarized the advantages and disadvantages of the various server models, I'll let you in on a secret. Web developers seldom choose based on rational criteria, such as which model fits their needs better than another. I certainly have rarely had that opportunity. In reality, the choice is usually driven by the available technology, your budget, the technologies used in an existing site, and the skills and experience of the available human resources. Going a step further, unless you develop for one organization and one organization only, and you intend to stay there for a very long time, you probably don't have the luxury to learn just one server-side language. Due to circumstances relating to my work situation, I initially learned ColdFusion and ASP simultaneously, because each was required for a different project I was working on.

Side by Side with ASP and Coldfusion: A Strategy for Learning

Don't be alarmed at the prospect of learning both at the same time. The truth is, in the vast majority of situations, if you need to add a block of ASP to handle some functionality, then you would also need to add an equivalent block of ColdFusion to handle the same functionality. And the hardest part is not the syntax of one or the other type of code, but rather understanding what data is available, where it is available, and deciding how to get it to do what you want. If you know that much, the syntax isn't that hard.

For this reason, this book uses both ASP and ColdFusion side by side. While you don't need to develop the same site twice so you can use both server models, you should make an effort to understand both sets of code. That is, if you decide to develop in ColdFusion, don't just skip the ASP code. Take a moment to see how the ASP code accomplishes the same thing as the ColdFusion code. If you can understand how both code blocks accomplish the same task, you will accelerate your mastery of Web programming.

For example, the following two code snippets perform the same function: They output (or display) a value that the user entered in an XHTML form field, called "firstName."

In ASP:

<p>Thank you, <% Response.Write(Request.Form("firstName")) %>, for your submission.</p>

NOTE

This symbol () lets you know that, within the book, the code has overflowed onto additional lines. As you enter the code in Dreamweaver, you should not use the Return key to separate these lines; simply continue to type. And don't try to insert an arrow into your code!


In ColdFusion:

<p>Thank you, <cfoutput>#form.firstName#</cfoutput>, for your submission.</p>

Let's review the similarities between these two code snippets.

  • Both use a special set of tags to indicate server markup. ASP uses <% and %>, while ColdFusion uses <cf[tagname]> and </cf[tagname]>. In this example, these tags are <cfoutput> and </cfoutput>.

  • Both indicate that they are outputting data: ASP uses Response.Write and ColdFusion uses <cfoutput>.

  • Both make explicit reference to the variable name (firstName), and both specify that this is a form variable: ASP uses Request.Form("firstName"), while ColdFusion uses #form.firstName#.

  • Neither contains any additional code beyond these three points.

You don't need to memorize this code; there won't be a quiz on it, and you'll get plenty of practice with it later. The point for now is to see the deep similarity between what the two snippets are doing: Both are requesting a form variable named firstName, and outputting it in the middle of a string of otherwise regular XHTML code. The differences between the two code snippets are therefore completely cosmetic: a matter of syntax and a matter of looking up something in a reference. The hardest part is understanding in the first place that you can capture a value entered in a form and send it back mixed in with plain-old XHTML code.

Throughout the book, then, I will present both sets of code side by side. In all cases, I will deconstruct what the code blocks are doing, so you should understand exactly what is going on. All you have to do is read both sets of code, and see how each accomplishes in its own way the functions that I outline in the main text.

But before you start getting neck-deep in code, you need to configure your system for dynamic site development.