- What You Will Learn
- Approximate Time
- Lesson Files
- Dynamic Web Site Basics
- Choosing a Server Model
- Redefining the Newland Tours Site for Dynamic Development
- Developing with a Local Server
- Setting Up a Local Environment for IIS/ASP
- Setting Up a Local Environment for ColdFusion
- Setting Up a Local Environment for Apache/PHP
- Developing with a Remote Server
- Defining a Dynamic Site in Dreamweaver (All Users)
- Building a Simple, Dynamic Application
- What You Have Learned
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) 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 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. It is also extremely easy to set up and configure.
PHP Hypertext Processor (PHP): A recursive 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. In PHP 4, used in this book, its code is comparable in difficulty to that of ASP—possibly a little easier. In the newly released PHP 5, the language has been upgraded to a more object-oriented approach, and as a consequence, it is much harder for newbies (though considerably better for seasoned object-oriented programmers). One disadvantage—and this is true of many open-source products—is 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 quick, 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 and architecturally different from classic ASP, ColdFusion, and PHP. 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. ASP.NET supports numerous development languages, but by far the two most prevalent are VisualBasic.NET and C#.
Java Servlet Pages (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. It is also extremely powerful—certainly the most powerful solution until the appearance of .NET, and certainly powerful enough to compete head-on with .NET. But its code, once again, is daunting for those new to dynamic Web site development.
This book provides coverage of ASP classic (hereafter just ASP), ColdFusion, and PHP. However, this is not specifically an ASP, ColdFusion, or PHP book. The book is designed to initiate readers into the concepts and practices of building database-driven, dynamic Web sites using Dreamweaver 8. 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. You will not be an ASP, ColdFusion, or PHP expert, but you should be able to get a code-oriented, nonbeginner’s ASP, ColdFusion, or PHP book 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 of learning just one. I initially learned ColdFusion and ASP simultaneously, because both were required for different projects I was working on.
Side by Side with ASP, ColdFusion, and PHP: A Strategy for Learning
Don’t be alarmed at the prospect of learning all three at the same time. The truth is, in the 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 or PHP 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 hard.
For this reason, this book uses ASP, ColdFusion, and PHP side by side. While you don’t need to develop the same site three times to use all three server models, you should make an effort to understand all three sets of code. That is, if you decide to develop in ColdFusion, don’t just skip the ASP and PHP code. Take a moment to see how the ASP and PHP code accomplishes the same thing as the ColdFusion code. If you can understand how all three code blocks accomplish the same task, you will accelerate your mastery of Web programming.
For example, the following three 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>
In ColdFusion:
<p>Thank you, <cfoutput>#form.firstName#</cfoutput>, for your submission.</p>
In PHP:
<p>Thank you, <?php echo $_POST['firstName']; ?>, for your submission.</p>
Let’s review the similarities between these three code snippets.
- All use a special set of tags to indicate server markup. ASP uses <% and %>, ColdFusion uses <cf[tagname]> and </cf[tagname]>, and PHP uses <?php and ?>.
- All indicate that they are outputting data: ASP uses Response.Write, ColdFusion uses <cfoutput>, and PHP uses echo.
- All make explicit reference to the variable name (firstName).
- All specify that this is a form/POST variable (form variables, as discussed later, are sent using POST): ASP uses Request.Form("firstName"), ColdFusion uses #form.firstName#, while PHP uses $_POST['firstName'].
- Neither contains any additional code beyond these four 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 three snippets are doing: All 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 three 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 all three 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 the three 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.