Terminology


In the introduction to this chapter, I teased you about what a web application is but stopped short of actually defining it. Simply put, a web application is a website that contains static and dynamic pages working together to facilitate interaction between a user and a web server. That clears it all up right? To sum up this rather lame attempt at defining web applications, think of what we've done so far. Up until this point, we've built simple web pages (static ones), pressed F12, and magically the page appeared in the browser window as it was intended. Nothing special was required from us, we didn't have to install anything on the computer to get it to work (aside from Dreamweaver), and best of all, we didn't have to manually write any code in the Code view of the web page. If we were to diagram the process involved for a user browsing to your static web page (assuming that it was hosted by a web hosting provider rather than by your computer), the process might resemble what's shown in Figure 21.1.

Figure 21.1. Static web pages follow a simple flow: The user requests the page and the web server displays it.


There are two major components that make up static web pages: the client and the web server. The client makes a request by typing the URL of your website into the address bar of their browser and clicking Enter. At this point, a request is made to the web server. The web server, recognizing this request, sends HTML back to the client, whose browser parses the content out of the HTML tags and displays the text, images, and media (what the original developer of the page intended to be seen) to the user. As a developer, this process is often referred to as client-side development because you're using simple client-side technologies such as HTML, CSS, or JavaScripttechnologies meant to be processed by the client browser and that require very little if anything from the actual web server.

Dynamic pages, on the other hand, work differently and to a certain extent are a bit more complex in their implementation. Dynamic pages contain instructions in the form of a scripting languageor, in the case of ASP.NET, a full-blown object-oriented programming language that gets processed on the web server. Sometimes the instructions or code is self-contained, sometimes it's mixed in with HTML code, but ultimately that code is processed and executed by a web server. If we were to diagram the process involved for a user browsing to your dynamic web page (assuming that it was hosted by a web hosting provider rather than by your computer), it might resemble the process shown in Figure 21.2.

Figure 21.2. Dynamic web pages follow a complex flow: The user interacts with the page, sends a request to the server, the server processes the request, and finally sends a response back the client.


Dynamic websites, like static websites, rely on the two client and server components. The fundamental difference however, is that the server has much more to do for dynamic web pages than it did for static web pages. Although the user still makes a request for the initial page, dynamic web pages rely on user interaction (typically through form elements) for further requests to be made to the server. With static websites, a single request is made to the page. Unless the user hyperlinks to another page, the information sits there, waiting to be read by the user. Dynamic websites facilitate interaction. Ultimately, there could be dozens, possibly hundreds, of requests made to the server by way of form objects, hyperlinks, and so on.

The process is actually simple: The user interacts with form objects (maybe types a username and password into a series of text boxes), clicks a button, and the request is sent to the server. The server recognizes that a request is being made and uses a server-side technology (ASP, ASP.NET, ColdFusion, or PHP) to process that request (maybe compare the values of the text boxes with a hard-coded username and password), and then sends a response back to the client. The response could be a page redirection to the main page after the user has logged in or it could be a friendly message indicating that the username and password combination they've typed in are invalid.

That's the point with dynamic web pages: You write the code in a page that figures out how to handle requests coming from the client. The pages are said to be dynamic because they're not just sitting on the client's browser waiting to be read or clicked. Rather, the information is dynamic, it facilitates user interaction and responds accordingly. Better yet, dynamic pages can use conditional logic and mathematical equations, send emails, write to the file system, andmost importantlyinteract with file storage mechanisms such as databases and XML files.

Web Applications

In the previous section, we outlined the differences between static client-side and dynamic server-side web pages. We said that dynamic server-side web pages welcome interaction from the end user by exposing a series of carefully crafted form objects. When the user submits the form (containing the form objects) to the web server for processing, the dynamic portions of the page kick in and process the incoming request. The result of the processing is ultimately piped back to the user in a friendly format (such as HTML).

Dynamic web pages, however, are merely cogs within a grander system; they are individual pages that make up a part of the whole if you will. In the web development world, dynamic web pages are parts of a web application. Ultimately, a web application consists of many dynamic web pages that perform numerous operations depending on various factors built into the pages. Figure 21.3 illustrates this example with more detail.

Figure 21.3. Web applications consist of numerous dynamic web pages that together make up the unique functionality of the application.


A web application could consist of numerous dynamic web pages, each performing its own unique task. In our Dorknozzle example, we might initially expose a simple login page. If the user logs in correctly, we take them to the main page. If the login attempt fails, however, the user is redirected back to the login page where they're given an error message. From the main page, a user can visit various other dynamic web pages such as the company directory (which pulls employee information from a database), the employee store (which pulls product information from a database), and perhaps an admin page reserved specifically for administrators. If the user is an admin, they're allowed to modify employee information, create new employees, and even delete existing employees. As you can see, all these dynamic pages working together make up a well-oiled web application.

As we've mentioned, web applications are made up of different components, otherwise known as tiers. These tiers make up the web architecture of your site. Ever heard of the term 3-tiered web application? In this scenario, the term tiered refers to the components or tiers that make up the web application as a whole. At the very least, you'll almost always have a 2-tiered web application: The first tier is that your users/clients will want to visit your site. The second tier is the web server on which the web application is hosted. The third tier could be the data tier, or where your data storage mechanism (database) resides. For the most part, the following tiers represent a traditional 3-tiered web application's architecture:

  • Presentation: The presentation tier is everything that your clients/users will see. Everything from the user interface, images, media, JavaScript (client-side logic), and CSS comprises the presentation tier.

  • Business Logic: The business logic is the code running on the server that contains processing instructions utilizing technologies such as ASP, ASP.NET, ColdFusion, or PHP.

  • Data: The data tier should and will be the lifeblood of your organization. Represented by a databaseor in some cases, a flat file (XML)the data tier contains all the user information, product information, usernames, and passwords for your web application.

All in all, web applications serve a valuable purpose in web development. Many web developers find it more convenient to use web applications in place of static pages. Although the time-to-market is slower for web applications than for static pages, maintenance and return on investment (ROI) far outweigh the time it takes to develop the application. After the web application has been developed, updating content within a database that ultimately appears within the browser is a snap. Furthermore, the look and feel (design) of the site can easily be separated from the content, essentially disconnecting the designer and the developer and ultimately making each portion of the web application autonomous.

For the past twenty or so chapters, we've been discussing the many facets of Dreamweaver that facilitate client-side development. As you've seen, working with web pages in the Dreamweaver Document window is simple. Flanked by the numerous panels in Dreamweaver's development environment, it's hard to disagree that working with static web pages is a breeze. Making the switch to dynamic web development is not easy. For this reason, an introduction to the different tiers of a web application and an in-depth discussion of the various parts is necessary before we make the leap to dynamic web development. In the next few sections, we'll dissect each of these tiers, discussing the detailed components that make up each tier.

Client-Side Technologies

The presentation tieror more specifically, what your users interact withis comprised of many different client-side web technologies all serving a specific purpose depending on the developer's intentions. As you've seen throughout the book thus far, client-side develoment can include the following technologies:

  • HTML/XHTML: Generally considered the foundation for all that is the web, HTML, and more recently XHTML, serves as the structural markup for client-side web pages. HTML/XHTML is hard to ignore when working with websites. Because the browser can only parse HTML/XHTML, even if you're working with server-side applications, HTML/XHTML is what is ultimately sent back to the client from the server.

  • CSS: As you've seen throughout the book, Cascading Style Sheets (CSS) provide the look or design of the client-side web page. Using CSS, designers can control the look of text, links, form objects, the page, and more.

  • JavaScript: Often referred to as client-side logic, JavaScriptwritten within a <script> tag nested within the <head> tag of the HTML documentexposes unique properties for working with conditional logic, calculations, validation, and more in a client-side web page.

  • Media Elements: Embedded into the web page using the <embed>/<object> HTML tag, media elements such as Flash, Director, video, audio, and more enhance the user experience by incorporating a unique multimedia experience that can be engaging and stunning.

At the risk of rehashing technologies and languages we've covered for the past twenty chapters, suffice it to say that client-side elements are still extremely important when working with server-side technologies. Server-side technologies are merely responsible for processing requests from the client. What the client sees in the response is ultimately going to be formatted using the "client-side" technologies we've already covered in the book.

Server-Side Technologies

As already mentioned, server-side technologies are software components that handle most, if not all, of the business logic in a web application. When a user submits data from a form (run on the client), that data is sent to the web server for processing. The web server, using a server-side technology, processes the form (maybe inserts data into a database), and then sends a response back to the client. The process is fairly straightforward and, save for a few minute details, the process is the same regardless of which server-side technology is being used to process the request.

Over the past 10 years, as the Web has matured, dozens of different server-side technologies have appeared. Most server-side technologies have a lot in common. For example, most of them interact with relational databases; they can process complex requests from web browsers and can write files to and read files from a file system. So which option is the best for you? Most are pretty much the same, so choosing an option isn't just a case of features. Web developers soon discover that the most important criteria for selecting a client-side technology is its flexibility, ease-of-use, maintainability, and then feature set. Will the option you choose allow you to easily access a database? Build objects to keep redundant code to a minimum? Process multiple simultaneous users quickly? It's a lot like buying a pair of jeans: go with what looks good and fits right. The four major technologies that we'll discuss throughout the book include (ordered alphabetically, not by preference):

  • ASP

  • ASP.NET

  • ColdFusion

  • PHP

Although Chapter 22, "Working with Server-Side Technologies," certainly goes into more detail, the following sections outline the four most popular server-side technologies, their nuances, and the positives and negatives for using each. My hope is that by the time you begin reading Chapter 22, you'll have picked the server-side technology to use with the Dorknozzle project.

ASP

ASP, or Active Server Pages, is a Microsoft-developed web-scripting language that took the web development world by storm when it was introduced in the mid 1990s. Like many other server-side technologies, ASP enables you to embed special instructions in HTML pages that can do a variety of tasks, such as connect to a database, perform looping instructions, conditionally test for certain values, send emails, and read from and write to the file system. ASP runs natively on Microsoft's IIS web server. What this means is that if you have Windows XP Pro, Windows Server 2000, or Windows Server 2003, ASP is already installed and ready to go.

Although ASP pages are generally written using VBScript (a derivative of Visual Basic), ASP also supports JavaScript. Furthermore, ASP supports ActiveX Data Objects (ADO) for connecting to databases, Collaboration Data Objects (CDO) for sending emails, and more.

  • Positives: Macromedia claims that ASP is used by roughly 60% of Dreamweaver users. What this means is that support is high and extensions are plentiful. Although the trend is slowly moving to support for ASP.NET, ASP is still the number one server-side technology used by Dreamweaver.

  • Negatives: ASP, like PHP and (to a certain extent) ColdFusion, is interpreted. What this means is that every time a page is sent to the server for processing, a DLL intercepts and interprets the ASP code line by line. This usually results in a much slower response than is the case with compiled technologies such as ASP.NET (and JSP and CGI of years past). Furthermore, support for "traditional ASP" is slowly fading. Microsoft has tried weaning developers over to the next generation technologyASP.NETfor quite some time.

ASP.NET

In 2001, Microsoft created a buzz in not only the web development world but in the Windows development world when it introduced the .NET initiative. The initiative's aim was simple: develop a line of products, platforms, and services that are interoperable for the developer and easy-to-use and integrate for the ordinary user. Flanked by platforms like the .NET Framework (ASP.NET, the Common Language Runtime, and the Framework Class Library), products such as Visual Studio.NET, MSN, Office, and web services built directly into MSN (such as Passport), .NET has risen as an initiative worthy of its hype.

Make no mistake about it, however, ASP.NET represents a small piece of the .NET pie. Built into the .NET Framework, ASP.NET represents Microsoft's next generation server-side technology. ASP.NET supports compiled code written in C++, C# (pronounced C Sharp), Visual Basic.NET (VB.NET), and JScript.NET (similar syntactically to JavaScript). Even better, ASP.NET allows separation of code from HTML formatting (called code-behind). Because the language can be compiled, it can run faster than its interpreted counterparts ASP and PHP.

  • Positives: ASP.NET is compiled not interpreted, which results in a faster user experience. HTML and code can be separated into code-behind, making designing and developing tasks easier for the appropriate individuals. ASP.NET is well integrated into other .NET products such as SharePoint Portal Server, Office, MSN, and more. Building ASP.NET pages that access components of other .NET products is a snap. Furthermore, ASP.NET relies on the .NET Framework, a managed environment for both web and Windows applications. Reliability and stability with ASP.NET are much greater than with other technologies. Lastly, ASP.NET supports development in many different languages. Have a C++ background? Try using C#. VB background? Use VB.NET. Your options are virtually limitless.

  • Negatives: Although ASP.NET has been around for four years or so, Dreamweaver's support for it is not nearly as rich as it is for traditional ASP. Although most of the functionality available in traditional ASP can be accomplished in ASP.NET, extensions are not as prominent with ASP.NET as they are for ASP.

NOTE

At the risk of sounding biased, I prefer ASP.NET over ASP, ColdFusion, or PHP. As a web developer, I've used nearly all the server-side technologies on the market, and personally feel that ASP.NET is faster, easier to install and set up, easier to learn, and well supported by numerous development tools including Dreamweaver. However, my preference shouldn't be yours. ASP is well supported by Dreamweaver and PHP is considered the "hot" technology in the web development industry. What you decide to work with is ultimately up to you.


ColdFusion

In early 2001, Macromedia acquired a company by the name of Allaire. With the acquisition, Macromedia also acquired a key server-side technology component named ColdFusion and the tool used to develop ColdFusion pages, ColdFusion Studio. Described as a rapid server-side scripting technology for creating web applications, ColdFusion uses a language called ColdFusion Markup Language (CFML) to interact with databases and dynamically created pages. CFML tags are embedded directly into HTML, and each command has a start tag and an end tag similar to HTML. Here's a simple CFML tag:

 <cfmytag>Content goes here</cfmytag> 

Each ColdFusion application is a set of pages with CFML commands in them. Developers can use the built-in functions, create their own, integrate COM (Microsoft's Component Object Model), C++, or Java components into their code, and even build their own components using ColdFusion Components (CFCs).

Now an essential technology in the Macromedia web development line, ColdFusion relies on the ColdFusion Application Server. After it's installed, the application server functions similar to the .NET Framework in that it closely monitors and manages ColdFusion web applications. Furthermore, you can use the ColdFusion Administrator, available as a standalone web application, to manage everything from data sources, memory usage, mail server properties, caching, error logs, and more.

  • Positives: Well supported and documented by Macromedia. Extremely stable in most cases. Dreamweaver includes numerous features for developing ColdFusion applications. Furthermore, free downloadable extensions are plentiful.

  • Negatives: Although the developer edition of ColdFusion is free, the standard and enterprise versions of ColdFusion are expensive, ranging anywhere from $1300 to $5000. Support is also expensive. Expect to pay a going rate of $500 for a support phone call, compared to Microsoft's $250 per support phone call. Because ColdFusion remains the only application server that costs money, its cost alone has traditionally been the major deterrent to its use.

PHP commands (called directives) are embedded into HTML pages between special tags (<? and ?>). These directives are handed off to the PHP engine by the web server, which then processes the directive and hands output back to the web server for display in the web browser.

  • Positives: Because of its relative "newness," PHP is extremely trendy and widely used. Numerous start-up kits make learning PHP easy and intuitive. Realizing PHP's growing potential, Macromedia has included rich features within Dreamweaver for working with PHP development. Lastly, PHP coexists with other open source movements such as Linux, Apache, and MySQL, making the overall development experience from OS to web server to database to server-side web technology totally free!

  • Negatives: Like traditional ASP, PHP is interpreted code, which makes the processing of PHP pages slower than compiled options like ASP.NET and ColdFusion. Furthermore, because PHP is an open source technology, support is limited to forums, blogs, and weak documentation provided by the PHP website. Lastly, PHP is limited in its support for object-oriented features, compared to ASP.NET which can be written using full-blown object oriented programming languages such as C++, C#, and VB.NET.

Database Options

Not too long ago, databases were the realm of specialized people. If a database was too slow, that was okay because it sat on a mainframe and processed inventory and payroll checks. Now, databases are everywhere, and they're hooked into seemingly every single web application. Today's databases need to be fast, reliable, and scalable. If a database goes down (or slows down), a company's revenue might suffer because its only sales channel might be an online catalog with a shopping cart connected to the database.

As you will see in Chapter 23, "A Database Primer," a database is a collection of information stored in logical containers called tables. Each table normally contains related information, such as user information, personal statistics, product data, inventory information, and much, much more. Depending on the database you use, extended features for working with databases exist such as stored procedures, triggers, views/queries, and security options.

Numerous databases exist for you to work with. In fact, more databases exist than do server-side web technologies. Like server-side technologies, the database you choose is ultimately up to you because most are interoperable with the various server-side web technologies on the market today. Factors for choosing a database include reliability, support for the server-side technology you plan to use, scalability (how easy is it to scale up as your company grows), and extensibility (how easy is it to back up information, restore it in case of failure, merge data in and out, and automate processes).

As with server-side technologies, dozens of databases are available, but I'll outline only the ones used in the scope of this book. Each database has its own strengths and drawbacks. Some are free and some cost thousands of dollars to license. The database options we'll discuss include (listed in alphabetical order, not personal preference):

  • Access

  • MSDE and SQL Server 2000

  • MySQL

NOTE

It's important to note that other database options exist. Oracle, IBM DB2, PostGre Ingres, Sybase, dBase, and FileMaker Pro are all viable alternatives. Because of page limitations, this book limits our development to the three databases mentioned in the previous bullet points. If you'd like more information on other databases including a comparison of features, please visit the companion website at www.dreamweaverunleashed.com.


Access

Access is Microsoft's database solution for developers and small companies alike who desire to build or house data within a small yet reliable store. Because Microsoft Access is cheap and easily attainable, it's usually the perfect choice for discussion and use in books such as this one. Although we won't be covering data access until Chapter 23, "A Database Primer," you might want to start thinking about the scope of your needs and choose a database accordingly. If you're a small company, looking for something cheap, reliable, and easy to use, then Access is for you. You can find more information on Access from Microsoft's website at http://www.microsoft.com/office/access. Here you can find the latest updates, news, and purchase information for Microsoft Access.

TIP

If you plan on purchasing Access, consider purchasing the Microsoft Office bundle (Access, Word, Outlook, PowerPoint, and Excel for the price of about $550 versus Access alone for about $400).


Because of its simplicity and attainability, Access is the database of choice for most of the projects in the rest of this book. That's not to say that we won't highlight specific features built into Dreamweaver (like access to Stored Procedures and Views) that handle interaction between other databases such as SQL Server 2000 and MySQL.

MSDE and SQL Server 2000

SQL Server 2000 is Microsoft's database solution for medium to large companies and enterprises. It's quite a bit more expensive than Access, generally requires its own "database server" (the third tier we looked at), and at times requires the hiring of a certified database administrator (DBA) to maintain. With that said, SQL Server 2000 offers a robust and scalable solution for larger web applications due in part to its unique core of features including online transaction processing (OLTP), indexing, data transformation services, profiling, a query analyzer, and a robust and intuitive database management system (DBMS) in Enterprise Manager. If you'd like more information regarding SQL Server 2000, visit the following Microsoft website: http://www.microsoft.com/sql.

I will assume that if you're reading this book, you probably don't want to invest in something as massive as SQL Server 2000 and that your needs are better suited to something free but just as powerful for testing and development purposes. If this is the case, Microsoft's SQL Server Desktop Engine or MSDE is perfect for you. MSDE is Microsoft's free database alternative to SQL Server 2000. It functions and stores data exactly as SQL Server 2000 does but is meant for development purposes only. After you get your feet wet with MSDE, you might think about upgrading to a more robust and licensed database in SQL Server 2000. For more information about MSDE, visit Microsoft's website at http://www.microsoft.com/sql/msde/downloads/default.asp.

NOTE

One of the pluses to using SQL Server 2000 is the DBMS Enterprise Manager. Its simplicity and navigation structure make working with SQL Server 2000 enjoyable and easy. With MSDE however, you don't automatically get Enterprise Manager. Instead, you must use the free Microsoft tool, Web Data Administrator. Web Data Administrator is Microsoft's free web-based DBMS for MSDE. It's not nearly as powerful as Enterprise Manager but it gets the job done, and it's free! For more information regarding Web Data Administrator, visit the companion website at www.dreamweaverunleashed.com.


As of this writing, Microsoft has announced SQL Server 2005. Server 2005 offers numerous revolutionary features including compiled code using C# and VB.NET running directly on the database server, ability for self-contained 10GB stand-alone databases similar to Access, XML Views, XPath queries to the XML Views, enhanced data-mining features using Microsoft Decision Trees and Clustering Algorithms (which allow users to query data and then let SQL Server analyze that data, uncover patterns and trends, and then make decisions in terms of providing feedback on that data to the web application), a debugger for SQL code running on the database (TSQL), and more.

MySQL

Although MySQL works well with many different server-side technologies, it is usually mentioned in the same breath as PHP. MySQL is a free, open-source relational database system, whose popularity on the database side matches PHP's popularity on the server side.

MySQL allows for blazing fast selection of data and comparable performance for data inserts and updates. The native command-line interface supports Linux, Windows, and Mac OS X environments. If you don't like the thought of messing around with a command-line interface, don't despair; MySQL also offers numerous GUI-based tools for administering a MySQL database including permissions, backups, restores, and queries.

NOTE

Don't let the words open source scare you away. Although MySQL was once used primarily by geeky hackers, MySQL has evolved into a full-functioning and respected database capable of any commercial operation. In fact, the entire Google search engine is built using MySQL technology!


Although MySQL doesn't support the myriad of features other enterprise databases such as SQL Server 2000 and Oracle do, advancements are being made. At the time of this writing, MySQL 5.0 is available for preview and includes features that other databases have implemented for years, including views, stored procedures, and more.

For more information on MySQL, visit the website at http://www.mysql.com.

Structured Query Language

Information contained within a database is useless unless you have the means of extracting it. The Structured Query Language (SQL), as you'll see in Chapter 24, "A SQL Primer," is the language that does just that; it allows for quick but sophisticated access to the database data through the use of queries. Queries pose questions and return the results to your web application. But don't think of SQL as simply a way of extracting information. SQL can accomplish a variety of tasks, allowing us to not only extract information from a database, but to add, modify, and delete information as well.

SQL has its origins in a language developed by IBM in the 1970s called SEQUEL (for Structured English QUEry Language), and is still often referred to today as "sequel." It's a powerful way of interacting with current database technologies and the tables that make them up. SQL has roughly 30 keywords and is the language of choice for simple and complex database operations alike. The statements you'll construct with these keywords range from the simple to complex strings of subqueries and table joins.

NOTE

Although all databases support basic SQL, others go well beyond the basics and incorporate their own proprietary syntax to support structured data, variables, error handling, flow control statements, loops, conditionals, transactions, and more. For instance, Microsoft's implementation of SQL is known as Transact-SQL or T-SQL. Oracle's implementation of SQL is known as Procedural Language SQL or PL/SQL. The list goes on and on.


Working with Data Source Names

To understand data source names is to understand how applications connect to database data through the web server's operating system. At this foundation lies Open DataBase Connectivity (ODBC), a standard database access method developed by the SQL Access group in 1992. The goal of ODBC is to make it possible to access any data from any application, regardless of which database management system is handling the data. ODBC manages this feat by inserting a middle layer, called a database driver, between an application and the DBMS. The purpose of this layer is to translate the application's data queries into commands that the DBMS understands. For this to work, both the application and the DBMS must be ODBC-compliant, that is, the application must be capable of issuing ODBC commands and the DBMS must be capable of responding to them.

Data Source Names (DSNs) provide connectivity to a database through an ODBC driver. The DSN contains a database name, directory, database driver, UserID, password, and other information. After you create a DSN for a particular database, you can use the DSN in an application to call information from the database.

In general there are three types of DSNs:

  • System DSN: Can be used by anyone who has access to the machine. DSN info is stored in the registry.

  • User DSN: Created for a specific user. Also stored in the registry.

  • File DSN: DSN info is stored in a text file with the DSN extension, usually in the root of the web application's directory.

One of the benefits of using Dreamweaver is that you don't have to create DSNs manually. Dreamweaver allows you to connect and create DSNs directly from its development environment. We'll get into this in more detail in Chapter 23.

NOTE

There is also what is known as a "DSN-less connection." Instead of using a DSN to connect to a database, the developer specifies the necessary information right in the application. With a DSN-less connection, the developer is free to use connection standards other than ODBC, such as Microsoft's OLEDB or Apple/IBM's OpenDoc (a standard meant to replace ODBC).





Macromedia Dreamweaver 8 Unleashed
Macromedia Dreamweaver 8 Unleashed
ISBN: 0672327600
EAN: 2147483647
Year: 2005
Pages: 237
Authors: Zak Ruvalcaba

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net