The Basics


If you're embarking on learning ColdFusion, then you undoubtedly have an interest in Web-based applications. ColdFusion is built on top of the Internet (and the World Wide Web), so a good understanding of the Internet and related technologies is a must before getting started.

There is no need to introduce you to the Internet and the Web. The fact that you're reading this book is evidence enough that these are important to you. The Web is everywhere, and Web-site addresses appear on everything from toothpaste commercials to movie trailers to cereal boxes to car showrooms. In August 1981, 213 host computers were connected to the Internet. By the turn of the millennium that number had grown to about 100 million! And most of them are accessing the Web.

What has made the World Wide Web so popular? Most people give two primary reasons:

  • Ease of use. Publishing and browsing for information on the Web are relatively easy.

  • Quantity of content. With millions of Web pages from which to choose and thousands more being created each day, there are sites and pages to cater to almost every surfer's tastes.

A massive potential audience awaits your Web site and the services it offers. Of course, massive competition awaits you too. Most Web sites still primarily consist of static information, sometimes dubbed "brochureware." That's sad, as the Web is a powerful medium and is capable of so much more. In addition to static text and images, your site could have features like:

  • Dynamic, data-driven Web pages

  • Database connectivity

  • Intelligent, user-customized pages

  • Sophisticated data collection and processing

  • Powerful report generation

  • Email interaction

  • Rich and engaging user interfaces

  • Access to any existing back-ends and systems

ColdFusion enables you to do all thisand more.

But you need to take a step back before starting ColdFusion development. As I mentioned, ColdFusion takes advantage of existing Internet technologies. As such, a prerequisite to ColdFusion development is a good understanding of the Internet, the World Wide Web, Web servers and browsers, and how all these pieces fit together.

NOTE

This chapter is an overview of the Internet and related terms and technologies. Developers with prior Internet development experience are free to skip to the next chapter, although a quick skim through the content presented here may still be beneficial.


The Internet

Much ambiguity and confusion surround the Internet, so we'll start with a definition. Simply put, the Internet is the world's largest network.

The networks found in most offices today are local area networks (LANs), that comprise a group of computers in relatively close proximity to each other and linked by special hardware and cabling (see Figure 1.1). Some computers are clients (more commonly known as workstations); others are servers (also known as file servers). All these computers can communicate with each other to share information.

Figure 1.1. A local area network (LAN) is a group of computers in close proximity linked by special cabling.


Now imagine a bigger networkone that spans multiple geographical locations. This type of network is typically used by larger companies with offices in multiple locations. Each location has its own LAN, which links the local computers together. All these LANs in turn are linked to each other via some communications medium. The linking can be anything from simple dial-up modems to high-speed T1 or T3 connections and fiber-optic links. The complete group of interconnected LANs, as shown in Figure 1.2, is called a wide area network (WAN).

Figure 1.2. A wide area network (WAN) is made up of multiple, inter connected LANs.


WANs are used to link multiple locations within a single company. But suppose you need to create a massive network that links every computer everywhere. How would you do this?

You'd start by running high-speed backbones, connections capable of moving large amounts of data at once, between strategic locationsperhaps large cities or different countries. These backbones would be similar to high-speed, multilane, interstate highways connecting various locations.

You'd build in fault tolerance to make these backbones fully redundant. That way, if any connection broke, at least one other way to reach a specific destination would be available.

You'd then create thousands of local links that would connect every city to the backbones over slower connectionslike state highways or city streets. You'd allow corporate WANs, LANs, and even individual users to connect to these local access points. Some would stay connected at all times, others would connect as needed.

You'd create a common communications language so that every computer connected to this network could communicate with every other computer.

Finally, you'd devise a scheme to uniquely identify every computer connected to the network. This would ensure that information sent to a given computer actually reached the correct destination.

Congratulations, you've just created the Internet!

Though this is an oversimplification, it's exactly how the Internet works.

The high-speed backbones do exist. Many are owned and operated by the large telecommunications companies.

The local access points, more commonly known as points of presence (POPs), are run by phone companies, online services, cable companies, and local Internet service providers (ISPs).

The common language is IP, the Internet protocol, except that the term language is a misnomer. A protocol is a set of rules governing behavior in certain situations. Diplomats learn local protocol to ensure that they behave correctly in foreign countries. The protocols ensure that no communication breakdowns or misunderstandings occur. Computers also need protocols to ensure that they can communicate with each other correctly and that data is exchanged correctly. IP is the protocol used to communicate across the Internet, so every computer connected to the Internet must be running a copy of IP.

The unique identifiers are IP addresses. Every computer, or host, connected to the Internet has a unique IP address. These addresses are made up of four sets of numbers separated by periods65.36.166.120, for example. Some hosts have fixed (or static) IP addresses, whereas others have dynamically assigned addresses (assigned from a pool each time a connection is made). Regardless of how an IP address is obtained, no two hosts connected to the Internet can use the same IP address at any given time. That would be like two homes having the same phone number or street address. Information would end up in the wrong place all the time.

Internet Applications

The Internet itself is simply a massive communications network and offers very little to most individual users. This is why it took 20 years for the Internet to become the phenomenon is it today.

The Internet has been dubbed the Information Superhighway, and that analogy is apt. Highways themselves aren't nearly as exciting as the places you can get to by traveling themand the same is true of the Internet. What makes the Internet so exciting are the applications that run over it and what you can accomplish with them.

The most popular application now is the World Wide Web. It is the Web that single-handedly transformed the Internet into a household word. In fact, many people mistakenly think that the World Wide Web is the Internet, which definitely isn't the case. Table 1.1 lists some of the more popular Internet-based applications.

Table 1.1. Some Internet-Based Applications

APPLICATION

DESCRIPTION

Email

Simple Mail Transfer Protocol (SMTP) is the most popular email transmission mechanism, and the Post Office Protocol (POP) is the most used mail access interface.

FTP

File Transfer Protocol is used to transfer files between hosts.

Gopher

This menu-driven document retrieval system was very popular before the creation of the World Wide Web.

IRC

Internet Relay Chat enables real-time, text-based conferencing over the Internet.

NFS

Network File System is used to share files among various hosts.

Newsgroups

Newsgroups are threaded discussion lists, of which thousands exist (accessed via NNTP).

Telnet

Telnet is used to log on to a host from a remote location.

VPN

Virtual Private Networks facilitate the secure access of private networks over the Internet.

WWW

The World Wide Web.


All these various applicationsand many othersuse IP to communicate across the Internet. The information transmitted by these applications is broken into packets, small blocks of data that are sent to a destination IP address. The application at the receiving end processes the received information.

DNS

IP addresses are the only way to uniquely specify a host. When you want to communicate with a hosta Web server, for exampleyou must specify the IP address of the Web server you are trying to contact.

As you know from browsing the Web, you rarely specify IP addresses directly. Instead, you specify a host name, such as www.forta.com (my Web site). If hosts are identified by IP addresses, how does your browser know which Web server to contact if you specify a host name?

The answer is the Domain Name Service (DNS). DNS is a mechanism that maps host names to IP addresses. When you specify the destination address www.forta.com, your browser sends an address resolution request to a DNS server asking for the IP address of that host. The DNS server returns an actual IP address, in this case 65.36.166.120. Your browser can then use this address to communicate with the host directly.

If you've ever mistyped a host name, you've seen error messages like the one in Figure 1.3, which tell you the host could not be found, or that no DNS entry was found for the specified host. These error messages mean the DNS server was unable to resolve the specified host name.

Figure 1.3. Mistyping a URL often causes Domain Name Service (DNS) errors.


DNS is never actually needed (with an exception I'll get to in a moment). Users always the option of specifying the name of a destination host by its IP address to connect to the host, but there are very good reasons not to:

  • IP addresses are hard to remember and easy to mistype. Users are more likely to find www.forta.com than they are 65.36.166.120.

  • IP addresses are subject to change. For example, if you switch service providers, you might be forced to use a new set of IP addresses for your hosts. If users identified your site only by its IP address, they'd never be able to reach your host if the IP address changed. Your DNS name, however, stays the same even if you switch IP address. You need to change only the mapping so the host name maps to the new, correct IP address. (Your new service provider usually handles that.)

  • IP addresses must be unique, but DNS names need not be. Multiple hosts, each with a unique IP address, can all share the same DNS name. This enables load balancing between servers, as well as the establishment of redundant servers (so that if a server goes down, another server will still process requests).

  • A single host, with a single IP address, can have multiple DNS names. This enables you to create aliases if needed. For example, ftp.forta.com, www.forta.com, and even just plain forta.com might point to the same IP address, and thus the same server.

DNS servers are special software programs. Your ISP will often host your DNS entries, so you don't need to install and maintain your own DNS server software.

You can host your own DNS server and gain more control over the domain mappings, but in doing so, you inherit the responsibility of maintaining the server. If your DNS server is down, there won't be any way of resolving the host name to an IP address, and no one will be able to find your site.

Intranets, Extranets, and Portals

Intranets and extranets were the big buzzwords a few years back, and while some of the hype has worn off, intranets and extranets are still in use and valuable. Not too long ago, most people thought "intranet" was a typo. But intranets and extranets soon became recognized as legitimate and powerful new business tools.

An intranet is nothing more than a private Internet. In other words, it is a private network, usually a LAN or WAN, that enables the use of Internet-based applications in a secure and private environment. As on the public Internet, intranets can host Web servers, FTP servers, and any other IP-based services. Companies have been using private networks for years to share information. Traditionally, office networks have not been information friendly. Old private networks didn't have consistent interfaces, standard ways to publish information, or client applications that were capable of accessing diverse data stores. The popularity in the public Internet has spawned a whole new generation of inexpensive and easy-to-use client applications. These applications are making their way back into the private networks. The reason intranets are now getting so much attention is that they are a new solution to an old problem.

Extranets take this new communication mechanism one step further. Extranets are intranet-style networks that link multiple sites or organizations using intranet technologies. Many extranets actually use the public Internet as their backbones and employ encryption techniques to ensure the security of the data being moved over the network.

Two things distinguish intranets and extranets from the Internet: who can access them, and where they can be accessed from. Don't be confused by hype surrounding applications that claim to be "intranet ready." If an application can be used over the public Internet, it will work on private intranets and extranets, too.

Portals, a more current buzzword, are also simply Web sites (intranets or extranets). What makes a portal a portal is the login experience (a single login is all that is required for access to all applications), and the screen layout (usually a collection of windows, with a different application running in each). But when all is said and done, a portal is a Web application that runs lots of other Web applications. So everything that applies to intranets and extranets applies to portals too.

Web Servers

As mentioned earlier, the most commonly used Internet-based application is now the World Wide Web. The recent growth of interest in the Internet is the result of growing interest in the World Wide Web.

The World Wide Web is built on a protocol called the Hypertext Transport Protocol (HTTP). HTTP is designed to be a small, fast protocol that is well suited for distributed, multimedia information systems and hypertext jumps between sites.

The Web consists of pages of information on hosts running Web-server software. The host is often referred to as the Web server, though this is technically inaccurate. The Web server is software, not the computer itself. Versions of Web server software can run on almost all computers. There is nothing intrinsically special about a computer that hosts a Web server, and no rules dictate what hardware is appropriate for running a Web server.

NOTE

The original World Wide Web development was all performed under various flavors of Unix. The majority of Web servers still run on Unix boxes, but this is changing. Now Web server versions are available for almost every major operating system. Web servers hosted on high-performance operating systems, such as Windows XP and Windows 2003, are becoming more popular. This is because Unix is still more expensive to run than Windows and is also more difficult for the average user to use. Windows XP (and 2003) (built on top of Windows NT) has proven to be an efficient, reliable, and cost-effective platform for hosting Web servers. As a result, Windows' slice in the Web server operating system pie is growing. At the same time, Linux (an open-source flavor of Unix) has grown in popularity as a Web platform thanks to its low cost, its robustness, and the fact that it is becoming more usable to less technical users.


What exactly is a Web server? A Web server is a program that "serves" Web pages upon request. Web servers typically don't know or care what they are serving. When a user at a specific IP address requests a specific file, the Web server tries to retrieve that file and send it back to the user. The requested file might be a Web page's HTML source code, a GIF image, a Flash file, a XML document, or an AVI file. It is the Web browser that determines what should be requested, not the Web server. The server simply processes that request, as shown in Figure 1.4.

Figure 1.4. Web servers process requests made by Web browsers.


It's important to note that Web servers typically don't care about the contents of these files. HTML code in a Web page, for example, is markup that the Web browsernot the serverwill process. The Web server returns the requested page as is, regardless of what the page is and what it contains. If HTML syntax errors exist in the file, those errors will be returned along with the rest of the page.

Connections to Web servers are made on an as-needed basis. If you request a page from a Web server, an IP connection is made over the Internet between your host and the host running the Web server. The requested Web page is sent over that connection, and the connection is broken as soon as the page is received. If the received page contains references to additional information to be downloaded (for example, GIF or JPG images), each would be retrieved using a new connection. To retrieve all of a Web page containing five pictures, for example, it takes at least six requests, or hits.

NOTE

This is why the number of hits is a misleading measure of Web server activity. When you hear of Web servers that receive millions of hits in one day, it might not mean that there were millions of visitors. Hits don't equal the number of visitors or pages viewed. In fact, hits are a useful measure only of changes in server activity.


Web servers often aren't the only IP-based applications running on a single host. In fact, aside from performance issues, there is no reason a single host cannot run multiple services. For example, a Web server, an FTP server, a DNS server, and an SMTP POP3 mail server can run at the same time. Each server is assigned a port address to ensure that the server application responds only to requests and communications from appropriate clients. If IP addresses are like street addresses, ports can be thought of as apartment or suite numbers. A total of 65,536 ports are available on every hostports 01023 are the Well Known Ports, ports reserved for special applications and protocols (such as HTTP). Vendor-specific applications that communicate over the Internet (such as America Online's Instant Messenger, Microsoft SQL Server, and the Real Media player) typically use ports 102449151. No two applications can share a port at the same time.

Most servers use a standard set of port mappings, and some of the more common ports are listed in Table 1.2.

Table 1.2. Common IP Port Numbers

PORT

USE

20

FTP

21

FTP

23

Telnet

25

SMTP

43

Whois

53

DNS

70

Gopher

79

Finger

80

HTTP

107

Remote Telnet service

109

POP2

110

POP3

119

NNTP

143

IMAP4, Interactive Mail Access Protocol version 4 (previously used by IMAP2)

194

IRC

220

IMAP3

389

LDAP, Lightweight Directory Access Protocol

443

HTTPS, HTTP running over secure sockets

540

UUCP, Unix-to-Unix Copy

1723

PPTP (used by VPN's, Virtual Private Networks)


Most Web servers use port 80, but you can change that. If desired, Web servers can be installed on nonstandard ports to hide Web servers, as well as host multiple Web servers on a single computer by mapping each one to a different port. But remember, if you do use a nonstandard port mapping, users will need to know the new port number.

NOTE

This discussion of port numbers is very important in ColdFusion, and we'll come back to it in a few pages.


Web Pages

Information on the World Wide Web is stored in pages. A page can contain any of the following:

  • Text

  • Headers

  • Lists

  • Menus

  • Tables

  • Forms

  • Graphics

  • Scripts

  • Style sheets

  • Multimedia

Web pages are constructed using a series of client-side technologies that are processed and displayed by Web browsers.

Web Browsers

Web browsers are client programs used to access Web sites and pages. The Web browser has the job of processing received Web pages and displaying them to the user. The browser attempts to display graphics, tables, forms, formatted text, or whatever the page contains.

The most popular Web browser in use is Microsoft Internet Explorer, though Firefox, a recently released open-source browser, is becoming increasingly popular. Other, lesser-used browsers exist too, for example Safari and Opera.

Web page designers have to pay close attention to the differences between browsers because different Web browsers support different HTML tags. Unfortunately, no one single browser supports every tag currently in use. Furthermore, the same Web page often looks different on different browsers; every browser renders and displays Web page objects differently. Even the same browser running on different operating systems will sometimes behave differently.

For this reason, most Web page designers use multiple Web browsers, and they test their pages in each one to ensure that the final output appears as intended. Without this testing, some Web site visitors won't see the pages you published correctly.

TIP

Dreamweaver MX (including Dreamweaver MX 2004), used to create Web pages, has its own built-in browser that is neither Microsoft Internet Explorer, nor Netscape Navigator, nor any other browser. To help you test your Web pages in as many browsers as possible, Dreamweaver MX allows you to define external browsers that may be launched to view your creations.


HTML

Web pages are plain text files constructed via Hypertext Markup Language (HTML). HTML is implemented as a series of easy-to-learn tags. Web-page authors use these tags to mark up a page of text. Browsers then use these tags to render and display the information for viewing.

HTML is constantly being enhanced with new features and tags. To ensure backward compatibility, browsers must ignore tags they don't understand. For example, if you use the <MARQUEE> tag in an effort to create a scrolling text marquee, browsers that don't support this tag display the marquee text but don't scroll the text.

Web pages also can contain hypertext jumps, which are links to other pages or Web sites. Users can click links to jump to either other pages on the same site or any page on any site.

Pages on a Web server are stored in various directories. When requesting a Web page, a user might provide a full path (directory and filename) to specify a particular document.

You can specify a default Web page, a page that is sent back to the user when only a directory is specified, with a Web server. These default pages are often called index.html or default.htm (or index.cfm for ColdFusion pages). If no default Web page exists in a particular directory, you see either an error message or a list of all the available files, depending on how the server is set up.

JavaScript

HTML is a page markup language. It enables the creation and layout of pages and forms, but not much else. Building intuitive and sophisticated user interfaces requires more than straight HTMLclient-side scripting is necessary, too. Scripting enables you to write code (small programs) that runs within Web browsers.

The most popular client-side scripting language is JavaScript, which is supported (more or less) by almost every browser out there. Here are just some of the things you can do with JavaScript:

  • Perform form-field validation

  • Pop open windows

  • Animate text and images

  • Create drop-down menus or navigation controls

  • Perform rudimentary text and numeric processing

NOTE

The other major client-side scripting language is VBScript (modeled on Visual Basic). But VBScript is supported only in Microsoft Internet Explorer and is less widely used than JavaScript.


Scripting enables developers to trap and process eventsthings that occur within the browser. For example, a page being loaded, a form being submitted, and the mouse pointer moving over an image are all events, and scripts can be automatically executed by the Web browser when these occur.

Script code is either embedded in the HTML file or stored in an external file and linked within the HTML code. Either way, the script is retrieved and processed by the Web browser.

CAUTION

Writing client-side scripts is more difficult than writing simple HTML. Not only are scripting languages harder to learn than HTML, there is an additional complexity in that various browsers support various levels of scripting. Writing portable scripts is possible, but it isn't a trivial undertaking.


Other Client Technologies

Most new browsers also enable the use of add-on technologies that are supported either directly or via plug-in modules. Some of the most significant ones are:

  • CSS (Cascading Style Sheets). Provide a means of separating presentation from content so that both can be more readily reused and managed.

  • DHTML (Dynamic HTML). A combination of HTML, scripting, and CSS that provides extremely rich and powerful user-interface options. DHTML is becoming increasingly important as a means to create sophisticated user-interfaces.

  • Java applets. Small programs that run within the Web browser (actually, they run within a Java Virtual Machine, but we won't worry about that just yet). Applets were popular in the late '90s but are seldom used now because they are hard to write, slow to download, and often incompatible with all the computers, operating systems, and browsers in use.

  • Macromedia Flash. A technology that is now embedded in over 98 percent of all browsers in use. Flash provides a mechanism for creating rich and portable interactive user interfaces (complete with audio, video, and animation, if needed), and Flash is being ported to all sorts of new platforms and devices.

URLs

So, now you know what Web servers, Web browsers, and Web pages are. The piece that links them all together is the URL.

Every Web page on the World Wide Web has an address. This is what you type into your browser to instruct it to load a particular Web page. These addresses are called Uniform Resource Locators (URLs). URLs aren't just used to identify World Wide Web pages or objects. Files on an FTP server, for example, also have URL identifiers.

World Wide Web URLs consist of up to six parts (see Figure 1.5) as explained in Table 1.3.

Figure 1.5. URLs usually consist of up to six parts.


Table 1.3. Anatomy of a URL

PART

DESCRIPTION

Protocol

The protocol to retrieve the object. This is usually http for objects on the World Wide Web. If the protocol is specified then it must be followed by :// (which separates the protocol from the host name).

Host

The Web server from which to retrieve the object. This is specified as a DNS name or an IP address.

Port

The host machine port on which the Web server is running. If omitted, the specified protocol's default port is used; for Web servers, this is port 80. If specified, the port must be preceded by a colon (:).

Path

Path to file to retrieve or script to execute.

File

The file to retrieve or the script to execute.

Query String

Optional script parameters. If a query string is specified, it must be preceded by a question mark (?).


Look at some sample URLs:

  • http://www.forta.com. This URL points to a Web page on the host www.forta.com. Because no document or path was specified, the default document in the root directory is served.

  • http://www.forta.com/. This URL is the same as the previous example and is actually the correct way to specify the default document in the root directory (although most Web browsers accept the previous example and insert the trailing slash automatically).

  • http://www.forta.com/books/. This URL also points to a Web page on the host www.forta.com, but this time the directory /books/ is specified. Because no page name was provided, the default page in the /books/ directory is served.

  • http://65.36.166.120/books/. This URL points to the same file as the previous example, but this time the IP address is used instead of the DNS name.

  • http://www.forta.com/books/topten.html. Once again, this URL points to a Web page on the www.forta.com host. Both a directory and a filename are specified this time. This retrieves the file topten.html from the /books/ directory, instead of the default file.

  • http://www.forta.com:81/administration/index.html. This is an example of a URL that points to a page on a Web server assigned to a nonstandard port. Because port 81 isn't the standard port for Web servers, the port number must be provided.

  • http://www.forta.com/cf/tips/syndhowto.cfm. This URL points to a specific page on a Web server, but not an HTML page. CFM files are ColdFusion templates, which are discussed later in this chapter.

  • http://www.forta.com/cf/tips/browse.cfm?search=mx. This URL points to another ColdFusion file, but this time a parameter is passed to it. A ? is always used to separate the URL itself (including the script to execute) from any parameter.

  • http://www.forta.com/cf/tips/browse.cfm?search=mx&s=1. This URL is the same as the previous example, with one additional parameter. Multiple parameters are separated by ampersands (the & character).

  • ftp://ftp.forta.com/pub/catalog.zip. This is an example of a URL that points to an object other than a Web page or script. The protocol ftp indicates that the object referred to is a file to be retrieved from an FTP server using the File Transfer Protocol. This file is catalog.zip in the /pub/ directory.

Links in Web pages are references to other URLs. When a user clicks a link, the browser processes whatever URL it references.

Hosts and Virtual Hosts

As already explained, the term host refers to a computer connected to the Internet. The host name is the DNS name used to refer to that machine.

A Web site is hosted on a host (which makes perfect sense, if you think about it). So host www.forta.com (which has an IP address of 65.36.166.120) hosts my Web site. But that host also hosts many other Web sites (some mine and some belonging to other people). If a request arrives at a host that hosts multiple Web sites, how does the host know which Web site to route it to?

There are actually several ways that this can be accomplished:

  • Earlier I explained that IP addresses must be unique, that is, no two hosts may share the same IP address. But what I didn't explain is that a single host may have more than one IP address (assuming the operating system allows this, and most do). If a host has multiple IP addresses, each may be mapped in the Web server software to virtual hosts. Each virtual host is has an associated Web root (the base directory for any and all content). Depending on the IP address that the request came in on, the Web server can route the request to the appropriate virtual host and directory structure.

  • Some Web servers allow multiple virtual hosts using the same IP address. How do they do this? By looking at the DNS name that was specified. You will recall that I earlier explained that multiple DNS names can resolve to the same IP address, and so Web servers may allow the mapping of virtual hosts by DNS name (rather than IP address). This is the instance I was referring to earlier when I said that there is a scenario in which DNS names must be used.

In both of these configurations, all of the hosts (including virtual hosts) are processed by the same Web server. There is another way to support multiple hosts without using different DNS names or IP addresses:

  • Depending on the Web server software being used, it may be possible to run multiple Web servers on the same computer. In this configuration each and every instance of the Web server must be running on a different port (you will recall that no two applications may share a port at the same time). When requests are made, the port must be specified in the URL (or else, as previously explained, the request will default to port 80). Each Web server has its own Web root, which is then the root for a specific virtual host.

In this configuration multiple Web servers are used, one per host.

The difference may seem subtle, but it's very important, as you will soon see.



Macromedia Coldfusion MX 7 Web Application Construction Kit
Macromedia Coldfusion MX 7 Web Application Construction Kit
ISBN: 321223675
EAN: N/A
Year: 2006
Pages: 282

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