developing apps

908
Developing ColdFusion MX Applications with CFML

Upload: la7jpress

Post on 10-Oct-2014

25 views

Category:

Documents


6 download

TRANSCRIPT

Developing ColdFusion MX Applications with CFML

Trademarks Afterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware Attain, Authorware Interactive Studio, Authorware Star, Authorware Synergy, Backstage, Backstage Designer, Backstage Desktop Studio, Backstage Enterprise Studio, Backstage Internet Studio, ColdFusion, Design in Motion, Director, Director Multimedia Studio, Doc Around the Clock, Dreamweaver, Dreamweaver Attain, Drumbeat, Drumbeat 2000, Extreme 3D, Fireworks, Flash, Fontographer, FreeHand, FreeHand Graphics Studio, Generator, Generator Developer's Studio, Generator Dynamic Graphics Server, JRun, Knowledge Objects, Knowledge Stream, Knowledge Track, Lingo, Live Effects, Macromedia, Macromedia M Logo & Design, Macromedia Flash, Macromedia Xres, Macromind, Macromind Action, MAGIC, Mediamaker, Object Authoring, Power Applets, Priority Access, Roundtrip HTML, Scriptlets, SoundEdit, ShockRave, Shockmachine, Shockwave, Shockwave Remote, Shockwave Internet Studio, Showcase, Tools to Power Your Ideas, Universal Media, Virtuoso, Web Design 101, Whirlwind and Xtra are trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words or phrases mentioned within this publication may be trademarks, servicemarks, or tradenames of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally. This product includes code licensed from RSA Data Security. This guide contains links to third-party websites that are not under the control of Macromedia, and Macromedia is not responsible for the content on any linked site. If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites. Apple Disclaimer APPLE COMPUTER, INC. MAKES NO WARRANTIES, EITHER EXPRESS OR IMPLIED, REGARDING THE ENCLOSED COMPUTER SOFTWARE PACKAGE, ITS MERCHANTABILITY OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. THE EXCLUSION OF IMPLIED WARRANTIES IS NOT PERMITTED BY SOME STATES. THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. THIS WARRANTY PROVIDES YOU WITH SPECIFIC LEGAL RIGHTS. THERE MAY BE OTHER RIGHTS THAT YOU MAY HAVE WHICH VARY FROM STATE TO STATE. Copyright 19992002 Macromedia, Inc. All rights reserved. This manual may not be copied, photocopied, reproduced, translated, or converted to any electronic or machine-readable form in whole or in part without prior written approval of Macromedia, Inc. Part Number ZCF60M800 Acknowledgments Project Management: Stephen M. Gilson Writing: Hal Lichtin, Stephen M. Gilson, Michael Stillman, David Golden Editing: Linda Adler, Noreen Maher

First Edition: May 2002 Macromedia, Inc. 600 Townsend St. San Francisco, CA 94103

CONTENTS

ABOUT THIS BOOK . . . . . . . . . . . . . . . . . . . . . . . . . . XXI

Using this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii Book structure and contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii Approaches to using this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii Developer resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiv About Macromedia ColdFusion MX documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv Printed and online documentation set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv Viewing online documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxvi Getting answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxvi Contacting Macromedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxviCHAPTER 1 Introduction to ColdFusion MX . . . . . . . . . . . . . . . . . . . . 1

About Internet applications and web application servers . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 About web pages and Internet applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 About web application servers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 About ColdFusion MX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 The ColdFusion scripting environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 ColdFusion Markup Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 ColdFusion application services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 The ColdFusion MX Administrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Using ColdFusion MX with Macromedia Flash MX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 About J2EE and the ColdFusion architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 About ColdFusion and the J2EE platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 J2EE infrastructure services and J2EE application server. . . . . . . . . . . . . . . . . . . . . . . . . . .8 ColdFusion features described in this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10

PART I The CFML Programming Language . . . . . . . . . . . . . . . . . . . . 13CHAPTER 2 Elements of CFML . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 Character case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Tag syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Built-in tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18

iii

Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Built-in functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 User-defined functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Variable scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 CFScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26 Flow control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 cfif, cfelseif, and cfelse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27 cfswitch, cfcase, and cfdefaultcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 cfloop and cfbreak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 cfabort and cfexit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30 Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Special characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32CHAPTER 3 Using ColdFusion Variables . . . . . . . . . . . . . . . . . . . . 33

Creating variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 Variable naming rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 Variable characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37 Booleans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 Date-Time values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 Binary data type and Base64 encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 Complex data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41 Using periods in variable references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 Understanding variables and periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46 Creating variables with periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 Data type conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49 Operation-driven evaluation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49 Conversion between types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49 Evaluation and type conversion issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51 Examples of type conversion in expression evaluation. . . . . . . . . . . . . . . . . . . . . . . . . . . .54 About scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 Scope types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55 Creating and using variables in scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57 Using scopes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59 Ensuring variable existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 Testing for a variables existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 Using the cfparam tag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61 Validating data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 Using cfparam to validate the data type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 Passing variables to custom tags and UDFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 Passing variables to CFML tags and UDFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 Passing variables to CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64

iv

Contents

CHAPTER 4

Using Expressions and Pound Signs . . . . . . . . . . . . . 65

Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66 Operator types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66 Operator precedence and evaluation ordering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 Using functions as operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 Using pound signs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71 Using pound signs in ColdFusion tag attribute values . . . . . . . . . . . . . . . . . . . . . . . . . . .71 Using pound signs in tag bodies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 Using pound signs in strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 Nested pound signs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 Using pound signs in expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 Dynamic expressions and dynamic variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 About dynamic variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 About dynamic expressions and dynamic evaluation. . . . . . . . . . . . . . . . . . . . . . . . . . . . .74 Dynamic variable naming without dynamic evaluation . . . . . . . . . . . . . . . . . . . . . . . . . .75 Using dynamic evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77 Using the IIF function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80 Example: a dynamic shopping cart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82CHAPTER 5 Using Arrays and Structures. . . . . . . . . . . . . . . . . . . . 87

About arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 Basic array concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 About ColdFusion arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 Basic array techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90 Referencing array elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90 Creating arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90 Adding elements to an array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92 Deleting elements from an array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 Copying arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94 Populating arrays with data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 Populating an array with the ArraySet function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 Populating an array with the cfloop tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95 Populating an array from a query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97 Array functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 About structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 Structure notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 Referencing complex structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100 Creating and using structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Creating structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Adding data elements to structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Updating values in structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Getting information about structures and keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103 Copying structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105 Deleting structure elements and structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 Looping through structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107 Structure example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109 Structure functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113

Contents

v

CHAPTER 6 Extending ColdFusion Pages with CFML Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115

About CFScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116 Comparing tags and CFScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116 The CFScript language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 Identifying CFScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118 Statement blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119 Reserved words. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 Differences from JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 CFScript limitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 CFScript functional equivalents to ColdFusion tags . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 Using CFScript statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 Using assignment statements and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 Using conditional processing statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 Using looping statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124 Handling exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129 CFScript example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130CHAPTER 7 Using Regular Expressions in Functions . . . . . . . . . 133

About regular expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Using ColdFusion regular expression functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134 Basic regular expression syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135 Regular expression syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 Using character sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136 Finding repeating characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 Case sensitivity in regular expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138 Using subexpressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138 Using special characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138 Using escape sequences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141 Using character classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143 Using backreferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144 Using backreferences in replacement strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144 Omitting subexpressions from backreferences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146 Returning matched subexpressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147 Specifying minimal matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149 Regular expression examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152 Regular expressions in CFML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152 Types of regular expression technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154

PART II Reusing CFML Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155CHAPTER 8 Reusing Code in ColdFusion Pages. . . . . . . . . . . . . 157

About reusable CFML elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158 Including pages with the cfinclude tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158 Using the cfinclude tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159

vi

Contents

Recommended uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160 Calling user-defined functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 Calling UDFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 Recommended uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 For more information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 Using custom CFML tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 Calling custom CFML tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 Recommended uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 For more information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Using CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 Calling CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 Recommended uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 For more information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 Using ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165 Creating and using ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165 Recommended uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165 For more information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165 Selecting among ColdFusion code reuse methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166CHAPTER 9 Writing and Calling User-Defined Functions . . . . . 167

About user-defined functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168 Calling user-defined functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 Creating user-defined functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 Creating functions using CFScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 Creating functions using tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 Rules for function definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 Defining functions in CFScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .174 Defining functions using the cffunction tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177 Calling functions and using variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Passing arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Referencing caller variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .180 Using function-only variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181 Using arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181 A User-defined function example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182 Defining the function using CFScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182 Defining the function using the cffunction tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183 Using UDFs effectively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 Using Application.cfm and function include files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 Specifying the scope of a function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .184 Using the Request scope for static variables and constants . . . . . . . . . . . . . . . . . . . . . . .186 Using function names as function arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186 Handling query results using UDFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .187 Identifying and checking for UDFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188 Using the Evaluate function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188 Passing complex data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189 Using recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190 Handling errors in UDFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191

Contents

vii

CHAPTER 10

Creating and Using Custom CFML Tags. . . . . . . . 197

Creating custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 Creating and calling custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 Securing custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201 Accessing existing custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201 Passing data to custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 Passing values to and from custom tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .202 Using tag attributes summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203 Custom tag example with attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204 Passing custom tag attributes using CFML structures . . . . . . . . . . . . . . . . . . . . . . . . . . .205 Managing custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 Securing custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 Encoding custom tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 Executing custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208 Accessing tag instance data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208 Handling end tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .208 Processing body text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210 Terminating tag execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211 Nesting custom tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212 Passing data between nested custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212 Variable scopes and special variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213 High-level data exchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213CHAPTER 11 Building and Using ColdFusion Components . . . . 217

About ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .218 Applying design patterns to component development. . . . . . . . . . . . . . . . . . . . . . . . . . .218 Building ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 Defining component methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220 Interacting with component methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222 Invoking component methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222 Passing parameters to component methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226 Returning values from component methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .232 Using advanced ColdFusion component functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . .234 Building secure ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234 Using component packages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237 Using component inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239 Using component metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .240CHAPTER 12 Building Custom CFXAPI Tags. . . . . . . . . . . . . . . 243

What are CFX tags? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244 Before you begin developing CFX tags in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 Sample Java CFX tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .245 Setting up your development environment to develop CFX tags in Java . . . . . . . . . . . . .245 Customizing and configuring Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246 Writing a Java CFX tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .247 Calling the CFX tag from a ColdFusion page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .247 Processing requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248 Loading Java CFX classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .250 Automatic class reloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .250 Life cycle of Java CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251

viii

Contents

ZipBrowser example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251 Approaches to debugging Java CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253 Outputting debugging information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253 Debugging in a Java IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253 Using the debugging classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .254 Developing CFX tags in C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 Sample C++ CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 Setting up your C++ development environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 Compiling C++ CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 Locating your C++ library files on Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 Implementing C++ CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256 Debugging C++ CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257 Registering CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257

PART III Developing CFML Applications . . . . . . . . . . . . . . . . . . . . . 259CHAPTER 13 Designing and Optimizing a ColdFusion Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

About applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262 Elements of a ColdFusion application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262 The application framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262 Application-level settings and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .263 Reusable application elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 Shared variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 Application security and user identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 Mapping an application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265 Processing the Application.cfm and OnRequestEnd.cfm pages. . . . . . . . . . . . . . . . . . . .265 Defining the directory structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266 Creating the Application.cfm page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268 Naming the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268 Setting the client, application, and session variables options . . . . . . . . . . . . . . . . . . . . . .268 Defining page processing settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269 Setting application default variables and constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269 Processing logins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269 Handling errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .270 Example: an Application.cfm page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .270 Optimizing ColdFusion applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .272 Caching ColdFusion pages that change infrequently . . . . . . . . . . . . . . . . . . . . . . . . . . .272 Caching parts of ColdFusion pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274 Optimizing database use. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277 Providing visual feedback to the user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280CHAPTER 14 Handling Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

About error handling in ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282 Understanding errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283 About error causes and recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283 ColdFusion error types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .284 About ColdFusion exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .284 How ColdFusion handles errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .287

Contents

ix

Error messages and the standard error format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .289 Determining error-handling strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .291 Handling missing template errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .291 Handling form field validation errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .291 Handling compiler exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .291 Handling runtime exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .292 Specifying custom error messages with cferror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .293 Specifying a custom error page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .293 Creating an error application page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .294 Logging errors with the cflog tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .297 Handling runtime exceptions with ColdFusion tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .299 Exception-handling tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .299 Using cftry and cfcatch tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .299 Using cftry: an example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .304 Using the cfthrow tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .308 Using the cfrethrow tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309 Example: using nested tags, cfthrow, and cfrethrow . . . . . . . . . . . . . . . . . . . . . . . . . . . .310CHAPTER 15 Using Persistent Data and Locking . . . . . . . . . . . . 315

About persistent scope variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .316 ColdFusion persistent variables and ColdFusion structures. . . . . . . . . . . . . . . . . . . . . . .317 ColdFusion persistent variable issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .317 Managing the client state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .318 About client and session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .319 Maintaining client identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320 Configuring and using client variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323 Enabling client variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .323 Using client variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .325 Configuring and using session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .328 What is a session? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .328 Configuring and enabling session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329 Storing session data in session variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .330 Standard session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .330 Getting a list of session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .331 Creating and deleting session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .331 Accessing and changing session variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .331 Ending a session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332 Configuring and using application variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 Configuring and enabling application variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 Storing application data in application variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333 Using application variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .334 Using server variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .335 Locking code with cflock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336 Sample locking scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336 Using the cflock tag with write-once variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .338 Using the cflock tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .338 Considering lock granularity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .341 Nesting locks and avoiding deadlocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .341 Examples of cflock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .343

x

Contents

CHAPTER 16

Securing Applications . . . . . . . . . . . . . . . . . . . . . . . 347

ColdFusion security features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348 About resource security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349 About user security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .351 Security tags and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .353 About web server authentication and application authentication . . . . . . . . . . . . . . . . . .353 Controlling ColdFusion login behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .354 The cflogin structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356 Using ColdFusion security without cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356 A basic authentication security scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356 An application authentication security scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .357 Implementing user security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .360 Basic authentication user security example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .360 Application-based user security example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362 Using application-based security with a browsers login dialog . . . . . . . . . . . . . . . . . . . .368 Using an LDAP Directory for security information . . . . . . . . . . . . . . . . . . . . . . . . . . . .369CHAPTER 17 Developing Globalized Applications . . . . . . . . . . . . 373

Introduction to globalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374 Defining globalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374 Importance of globalization ColdFusion applications . . . . . . . . . . . . . . . . . . . . . . . . . . .375 How ColdFusion supports globalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375 Character sets and locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375 About character encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .377 The Unicode character encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .377 Locales. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378 Setting the locale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378 Processing a request in ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379 Determining the character set of a ColdFusion page. . . . . . . . . . . . . . . . . . . . . . . . . . . .379 Determining the character set of server output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .380 Tags and functions for globalizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382 Using tags for globalizing applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382 Using functions for globalizing applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382 Handling data in ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385 Input data from URLs and HTML forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385 Reading and writing file data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387 Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387 E-mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387 HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387 LDAP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388 WDDX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388 COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388 CORBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388 Searching and indexing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388CHAPTER 18 Debugging and Troubleshooting Applications . . .389

Configuring debugging in the ColdFusion MX Administrator. . . . . . . . . . . . . . . . . . . . . .390 Debugging Settings page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .390 Debugging IP addresses page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .392

Contents

xi

Using debugging information from browser pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .393 General debugging information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .394 Execution Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .395 Database Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .397 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .399 Trace points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .399 Scope variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .400 Using the dockable.cfm output format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .400 Controlling debugging information in CFML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .402 Generating debugging information for an individual query . . . . . . . . . . . . . . . . . . . . . .402 Controlling debugging output with the cfsetting tag . . . . . . . . . . . . . . . . . . . . . . . . . . .402 Using the IsDebugMode function to run code selectively . . . . . . . . . . . . . . . . . . . . . . . .403 Using the cftrace tag to trace execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .404 About the cftrace tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .404 Using tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .406 Calling the cftrace tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .407 Using the Code Compatibility Analyzer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .409 Troubleshooting common problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .410 CFML syntax errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .410 Data source access and queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .411 HTTP/URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .411

PART IV

Accessing and Using Data . . . . . . . . . . . . . . . . . . . . . . . . . 413Introduction to Databases and SQL. . . . . . . . . . . . 415

CHAPTER 19

What is a database? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416 Using multiple database tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .417 Database permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418 Commits, rollbacks, and transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418 Database design guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .419 Using SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .420 SQL example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .420 Basic SQL syntax elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .421 Reading data from a database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .422 Modifying a database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .425 Writing queries using an editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .428 Writing queries using Dreamweaver MX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .428 Writing queries using ColdFusion Studio and Macromedia HomeSite+. . . . . . . . . . . . .430CHAPTER 20 Accessing and Retrieving Data . . . . . . . . . . . . . . .433

Working with dynamic data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .434 Retrieving data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .435 The cfquery tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .435 The cfquery tag syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .435 Building queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .436 Outputting query data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .438 Query output notes and considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .439 Getting information about query results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .441 Query variable notes and considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .442

xii

Contents

Enhancing security with cfqueryparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .443 About query string parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .443 Using cfqueryparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .443CHAPTER 21 Updating Your Database . . . . . . . . . . . . . . . . . . . . 445

About updating your database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .446 Inserting data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .446 Creating an HTML insert form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .446 Data entry form notes and considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .448 Creating an action page to insert data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .448 Updating data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .452 Creating an update form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .452 Creating an action page to update data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .455 Deleting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .459 Deleting a single record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .459 Deleting multiple records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .460CHAPTER 22 Using Query of Queries . . . . . . . . . . . . . . . . . . . . . . 461

About record sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .462 Referencing queries as objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .462 Creating a record set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .462 Creating a record set with a function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .463 About Query of Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .465 Benefits of Query of Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .465 Performing a Query of Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .465 Query of Queries user guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .474 Using dot notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .474 Using joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .474 Using unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .474 Using conditional operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .477 Using aggregate functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .480 Using group by and having expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .481 Using ORDER BY clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .481 Using aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .482 Handling null values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .483 Escaping reserved keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .483 BNF for Query of Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .486CHAPTER 23 Managing LDAP Directories . . . . . . . . . . . . . . . . .489

About LDAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .490 The LDAP information structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .492 Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .492 Attribute. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .492 Distinguished name (DN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .493 Schema. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .493 Using LDAP with ColdFusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .495 Querying an LDAP directory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .496 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .496 Search filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .496

Contents

xiii

Getting all the attributes of an entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .498 Example: querying an LDAP directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .498 Updating an LDAP directory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .503 Adding a directory entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .503 Deleting a directory entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .509 Updating a directory entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .510 Adding and deleting attributes of a directory entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . .512 Changing a directory entrys DN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .513 Advanced topics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .514 Specifying an attribute that includes a comma or semicolon . . . . . . . . . . . . . . . . . . . . . .514 Using cfldap output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .514 Viewing a directory schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .514 Referrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .519 Managing LDAP security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .520CHAPTER 24 Building a Search Interface . . . . . . . . . . . . . . . . . . 521

About Verity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .522 Using Verity with ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .522 Advantages of using Verity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .523 Supported file types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .523 Support for international languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .526 Creating a search tool for ColdFusion applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .528 Creating a collection with the ColdFusion MX Administrator . . . . . . . . . . . . . . . . . . . .528 About indexing a collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .530 Indexing and building a search interface with the Verity Wizard . . . . . . . . . . . . . . . . . .530 Creating a ColdFusion search tool programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . .535 Using the cfsearch tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .542 Working with record sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .545 Indexing database record sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .545 Indexing cfldap query results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .549 Indexing cfpop query results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .550 Using database-directed indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .551CHAPTER 25 Using Verity Search Expressions . . . . . . . . . . . . .553

About Verity query types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .554 Using simple queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .555 Stemming in simple queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .555 Preventing stemming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .557 Using explicit queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .558 Using AND, OR, and NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .558 Using wildcards and special characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .559 Composing search expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .562 Case sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .562 Prefix and infix notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .562 Commas in expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .562 Precedence rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .563 Delimiters in expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .563 Operators and modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .563 Refining your searches with zones and fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .573

xiv

Contents

PART V

Requesting and Presenting Information . . . . . . . . . . . . . . . 577Retrieving and Formatting Data . . . . . . . . . . . . . . 579

CHAPTER 26

Using forms to specify the data to retrieve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .580 HTML form tag syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .580 Form controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .581 Form notes and considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .584 Working with action pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .585 Processing form variables on action pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .585 Dynamically generating SQL statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .585 Creating action pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .586 Testing for a variable's existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .587 Requiring users to enter values in form fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .588 Form variable notes and considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .588 Working with queries and data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .589 Using HTML tables to display query results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .589 Formatting individual data items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .590 Building flexible search interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .591 Returning results to the user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .593 Handling no query results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .593 Returning results incrementally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .594 Dynamically populating list boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .597 Creating dynamic check boxes and multiple-selection list boxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .599 Check boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .599 Multiple selection lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .601 Validating form field data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .603CHAPTER 27 Building Dynamic Forms . . . . . . . . . . . . . . . . . . . . 607

Creating forms with the cfform tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .608 Using HTML and cfform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .608 The cfform controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .608 Preserving input data with preservedata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .609 Browser considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .610 Building tree controls with cftree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .611 Grouping output from a query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .612 The cftree form variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .613 Input validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .614 Structuring tree controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .614 Image names in a cftree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .616 Embedding URLs in a cftree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .617 Specifying the tree item in the URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .618 Building drop-down list boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .619 Building text input boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .620 Building slider bar controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .621 Creating data grids with cfgrid. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .622 Working with a data grid and entering data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .622 Creating an editable grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .624

Contents

xv

Embedding Java applets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .633 Registering a Java applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .633 Using cfapplet to embed an applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .635 Handling form variables from an applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .636 Input validation with cfform controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .637 Validating with regular expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .637 Input validation with JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .642 Handling failed validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .642 Example: validating an e-mail address. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .643CHAPTER 28 Charting and Graphing Data . . . . . . . . . . . . . . . . .645

Creating a chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .646 Chart types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .646 Creating a basic chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .647 Administering charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .649 Charting data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .650 Charting a query. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .650 Charting individual data points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .653 Combining a query and data points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .654 Charting multiple data collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .654 Writing a chart to a variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .656 Controlling chart appearance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .658 Common chart characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .658 Setting x-axis and y-axis characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .660 Creating a bar chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .661 Setting pie chart characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .662 Creating an area chart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .664 Setting curve chart characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .666 Linking charts to URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .667 Dynamically linking from a pie chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .667 Linking to JavaScript from a pie chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .670CHAPTER 29 Using the Flash Remoting Service . . . . . . . . . . . . 673

About using the Flash Remoting service with ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . .674 Planning your Flash application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .674 Using the Flash Remoting service with ColdFusion pages . . . . . . . . . . . . . . . . . . . . . . . . .675 Using Flash with ColdFusion components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .680 Using the Flash Remoting service with server-side ActionScript. . . . . . . . . . . . . . . . . . . . .682 Using the Flash Remoting service with ColdFusion Java objects . . . . . . . . . . . . . . . . . . . .683 Handling errors with ColdFusion and Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .684

PART VI Using Web Elements and External Objects . . . . . . . . . . . . 685CHAPTER 30 Using XML and WDDX . . . . . . . . . . . . . . . . . . . . . . 687

About XML and ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .688 The XML document object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .689 A simple XML document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .689 Basic view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .690

xvi

Contents

DOM node view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .690 XML document structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .691 ColdFusion XML tag and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .694 Using an XML object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .696 Referencing the contents of an XML object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .696 Assigning data to an XML object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .697 Creating and saving an XML document object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .698 Creating a new XML document object using the cfxml tag. . . . . . . . . . . . . . . . . . . . . . .698 Creating a new XML document object using the XmlNew function. . . . . . . . . . . . . . . .698 Creating an XML document object from existing XML . . . . . . . . . . . . . . . . . . . . . . . . .699 Saving and exporting an XML document object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .699 Modifying a ColdFusion XML object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .700 Functions for XML object management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .700 Treating elements with the same name as an array . . . . . . . . . . . . . . . . . . . . . . . . . . . . .701 XML document object management reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .702 Adding, deleting, and modifying XML elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .703 Using XML and ColdFusion queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .708 Transforming documents with XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .710 Extracting data with XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .711 Example: using XML in a ColdFusion application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .712 Moving complex data across the web with WDDX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .717 Uses of WDDX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .717 How WDDX works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .718 Using WDDX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .722 Using the cfwddx tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .722 Validating WDDX data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .722 Using JavaScript objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .723 Converting CFML data to a JavaScript object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .723 Transferring data from the browser to the server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .723 Storing complex data in a string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .726CHAPTER 31 Using Web Services . . . . . . . . . . . . . . . . . . . . . . . . .729

Web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .730 Accessing a web service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .730 Basic web service concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .731 Working with WSDL files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .733 Creating a WSDL file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .733 Viewing a WSDL file using Dreamweaver MX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .733 Reading a WSDL file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .734 Consuming web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .736 About the examples in this section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .736 Passing parameters to a web service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .736 Handling return values from a web service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .737 Using cfinvoke to consume a web service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .737 Using CFScript to consume a web service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .739 Calling web services from a Flash client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .740 Catching errors when consuming web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .740 Handling inout and out parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .740 Configuring web services in the ColdFusion Administrator . . . . . . . . . . . . . . . . . . . . . .741 Data conversions between ColdFusion and WSDL data types . . . . . . . . . . . . . . . . . . . .741

Contents

xvii

Consuming ColdFusion web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .742 Publishing web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .744 Creating components for web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .744 Specifying data types of function arguments and return values . . . . . . . . . . . . . . . . . . . .744 Producing WSDL files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .745 Using ColdFusion components to define data types for web services . . . . . . . . . . . . . . .748 Securing your web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .749 Best practices for publishing web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .752 Handling complex data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .753 Consuming web services that use complex data types . . . . . . . . . . . . . . . . . . . . . . . . . . .753 Publishing web services that use complex data types . . . . . . . . . . . . . . . . . . . . . . . . . . . .756CHAPTER 32 Integrating J2EE and Java Elements in CFML Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759

About ColdFusion, Java, and J2EE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .760 About ColdFusion and client-side JavaScript and applets . . . . . . . . . . . . . . . . . . . . . . . .760 About ColdFusion and JSP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .760 About ColdFusion and Servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .761 About ColdFusion and Java objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .761 Using JSP tags and tag libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .762 Using a JSP tag in a ColdFusion page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .762 Example: using the random tag library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .763 Interoperating with JSP pages and servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .764 Integrating JSP and servlets in a ColdFusion application . . . . . . . . . . . . . . . . . . . . . . . .764 Examples: using JSP with CFML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .766 Using Java objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .769 Using basic object techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .769 Creating and using a simple Java class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .771 Java and ColdFusion data type conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .774 Handling Java exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .776 Examples: using Java with CFML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .777CHAPTER 33 Integrating COM and CORBA Objects in CFML Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785

About COM and CORBA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .786 About objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .786 About COM and DCOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .786 About CORBA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .786 Creating and