1. Trang chủ
  2. » Công Nghệ Thông Tin

ColdFusion MX Bible phần 9 doc

124 925 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề ColdFusion MX Administration
Thể loại Phần
Năm xuất bản 2003
Thành phố N/A
Định dạng
Số trang 124
Dung lượng 1,12 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

In ColdFusion Administrator, enter CFMXDatabase or the name of your own SQL Server database in the Database field and 127.0.0.1 in the Server field.. pack-Verity Collections The Verity C

Trang 1

2 For this example, we previously created a database named CFMXDatabase in SQL

Server Enterprise Manager, as shown in Figure 43-13 (Note that you would replaceCFMXDatabase with your own SQL Server database Setting up this database is beyondthe scope of this book, as it has more to do with SQL Server administration thanColdFusion.)

Figure 43-13: The database in

SQL Server Enterprise Manager

3 In ColdFusion Administrator, enter CFMXDatabase (or the name of your own SQL Server

database) in the Database field and 127.0.0.1 in the Server field For the username and

password, of course, use whatever you set up for this purpose (In this example, weenter CFMXUser and the CFMXUser’s password.) Keep the default port of 1443 andenter a brief description After you finish, the form looks as shown in Figure 43-14 (withyour own database name, username and password, of course)

Figure 43-14: The datasource settings form.

4 Click Submit, and you’re taken back to the list of datasources, where the new

data-source now appears with an “ok” beside it

And that’s it Now, simply referring to CFMXBibleExample in your CFQUERY and CFSTOREDPROCtags gives you access to the CFMXDatabase database

Most datasource setups are about the same, although some target databases that require adifferent set of parameters from those shown for SQL Server The Oracle driver, for example,communicates with an Oracle database by using a different set of parameters, as you see inthe following section

Trang 2

Defining a new Oracle datasource

The process of setting up an Oracle datasource is similar to the one that we describe in thepreceding section for SQL Server, but Oracle requires different connection parameters Just

as you do with SQL Server, you start by clicking the Data Sources link under Data &

Services on the left-hand panel of Administrator (Note: The Oracle driver is available only

with ColdFusion MX Enterprise.) Then just follow these steps:

1 In the Add New Data Source section, enter the name of the new datasource (in this

example, we’re calling it CFMXBibleOracle) and choose Oracle as the driver type; thenclick Add

Our Oracle installation in this example has a SID (Service ID) named CFMXServer and auser named CFMXUser Note that administering Oracle is beyond the scope of thisbook; the database, username, and password used in this example should be replacedwith your own values

2 In ColdFusion Administrator, enter CFMXServer in the SID Name field and CFMXUser in

the Username field Then enter the password, leave the default port of 1521, enter abrief description, and click Submit

The built-in Type 4 Oracle driver supports multiple result sets returned from Oracle ages See Listing 10-24 in Chapter 10 for a very scalable way to accomplish this task

pack-Verity Collections

The Verity Collections page of ColdFusion Administrator (shown in Figure 43-15) enables you

to manage your Verity collections Here you can create new collections, or you can index,repair, optimize, purge, or delete an existing collection without resorting to writing code

This section assumes that you are familiar with Verity and its terminology If you are not,please read the Verity section of Chapter 32

To create a new collection, just enter the name of the collection, the collection’s language,and the name of the directory where you want the collection to be created The default is

cf_root\verity\collections

To index a collection, click the Index Collection icon next to the name of the collection thatyou want to index (This icon is the farthest left.) The indexing utility in Administrator gives

you the capability to do only a path index; if you want to use file or custom indexing you must

use a manually coded call to CFINDEX

Occasionally, a collection may become unstable and start producing incorrect results If thishappens, try repairing the collection (The icon that you click to start this task is the secondfrom the left.) Repairing the collection may take a long time, so don’t rush it, and especiallydon’t try to do anything else with the collection until Administrator is finished

Optimizing a collection makes it run faster To optimize a collection, click the middle iconnext to the name of the collection Optimizing the collection may take a few minutes

The fourth icon from the left purges the collection, removing all entries from the collectionbut leaving the empty collection intact The last icon, next to the collection name, deletes thecollection entirely

The bottom section of this Administrator page shows all collections currently available from

an attached Verity K2 Server No actions may be performed in this section, because K2Collections are managed through an INI file as part of the setup process for Verity K2 Server

Note

Trang 3

Figure 43-15: The Verity Collections page.

Verity K2 Server

The Verity K2 Server page of ColdFusion Administrator manages ColdFusion’s connection

to Verity K2 Server, the standalone server software that ships with ColdFusion as a performance alternative to ColdFusion Server’s built-in Verity routines This page is shown

high-in Figure 43-16:

Figure 43-16: The Verity K2 Server page.

The Add Verity K2 Server section of the page is where you tell ColdFusion which K2 Server toconnect to You just need to specify the name (or IP address) and port number of the serverwhere Verity K2 is running in the appropriate fields

Connected Verity Collections is a misnomer; it should be called Connected Verity Server Thissection of the page tells you which K2 Server is currently connected to the ColdFusion Serverand whether the K2 Server is online You can disconnect from the K2 Server by clicking thered X next to the server name

Trang 4

The Connected Verity K2 Collections section tells you which collections the K2 Serverexposes You can’t do anything to maintain or modify these collections, because they aremanaged by K2 Server’s INI file.

Web Services

The Web Services page of ColdFusion Administrator (shown in Figure 43-17) is where youmanage ColdFusion’s connections to Web services This form has two sections: Add / EditColdFusion Web Service and Active ColdFusion Web Services

Figure 43-17: The Web Services page.

The Add / Edit ColdFusion Web Service is where you set up the Web-service URLs and theusernames and passwords that they require You can assign a name to a Web-service URLhere and use the name as an alias in the Webservice attribute of your CFINVOKE tags Theusername and password are passed to the Web service’s basic authentication mechanismafter a request for service is made

Active ColdFusion Web Services describes the Web services to which ColdFusion is currentlysubscribed Each one can be edited, refreshed, or deleted Refreshing a Web-service connec-tion releases it from ColdFusion’s cache, reestablishes the WSDL interface to that Web ser-vice, and keeps the Web service’s name unchanged, whereas removing a Web servicepermanently removes its name

Debugging & Logging

This section of Administrator is focused more on debugging code than on configuringColdFusion Server From here, you can configure debugging output, view log files, and set upsystem probes This section also includes scheduled tasks and a tool to analyze existingColdFusion code to help determine incompatibilities with ColdFusion MX The followingsections describe each of these settings

Debugging Settings

The Debugging Settings page of ColdFusion Administrator is where you turn on debuggingand manage other performance monitoring settings This page is shown in Figure 43-18:

Trang 5

Figure 43-18: The Debugging Settings page.

Trang 6

Following are the four major settings on this page, each of which is described in the four tions that follow:

sec-✦ Enable Debugging

✦ Enable Robust Exception Information

✦ Enable Performance Monitoring

✦ Enable CFSTAT

Enable Debugging

This check box also controls all the options in the Custom Debugging Output section If thischeck box is disabled, no debugging output is shown regardless of the settings in the CustomDebugging Output section

Enable Robust Exception Information

Normally, ColdFusion’s default error message shows you only the error message and detail Ifthis option is selected, ColdFusion includes the following extra information along with theerror message:

✦ Physical path of template

✦ URI of template

✦ Line number and line snippet

✦ SQL statement used (if any)

✦ Data source name (if any)

✦ Java stack trace

Enable Performance Monitoring

If this option is enabled, ColdFusion Server publishes its performance metric data so thatWindows Performance Monitor can process it Among the many metrics published are thefollowing:

✦ Running Requests

✦ Queued Requests

✦ Page Hits/sec

✦ DB Hits/secAlways enable this option if you’re load-testing your application If your load-testing suite is agreat one, such as e-TEST Suite from Empirix, it can parallel this data with the other perfor-mance metrics from your application and its supporting database servers and Web servers

Do make sure that you keep this option off in production environments, however, becausepublishing these metrics causes a performance hit

Trang 7

Debugging IP Addresses

The Debugging IP Addresses page of ColdFusion Administrator tells ColdFusion what IPaddresses are allowed to receive debugging information This page is shown in Figure 43-19:

Figure 43-19: The Debugging IP Addresses page.

You may want to restrict debugging information to a single IP address (usually 127.0.0.1),meaning that only users accessing ColdFusion from a certain location may see debugginginformation Restricting this list to only those addresses of developers’ machines is usually agood idea

Trang 8

You’ve probably never paid much attention to this page, but it is one of the more importantpages in ColdFusion Administrator From here, you can turn on the logging of slow pages andscheduled tasks, which helps you discover performance bottlenecks and related problems.

This page offers the following options:

✦ Log Directory: This directory is where ColdFusion stores its log files to Changing this

value from the default probably isn’t a good idea Most tools assume that theColdFusion log files are in this directory, and you shouldn’t have any reason to changeits location

✦ Maximum File Size: This size limit is specified in kilobytes After the log reaches this

size, it is automatically archived See the next section for details on how these archivesare stored

✦ Maximum Number of Archives: After this number of archives is reached, the oldest is

automatically deleted

✦ Log Slow Pages Taking Longer than x Seconds: By default, this option is disabled.

Enable this feature to discover any potential bottlenecks in your system

✦ Log All CORBA Calls: Enabling this option is probably not a good idea if your site is

very CORBA-intensive, but it can be a useful debugging tool because you can use thelog files to inspect every call to a CORBA object

✦ Enable Logging for Scheduled Tasks: If this option is on, all scheduled tasks are logged

as they are executed

Log Files

The Log Files page of ColdFusion Administrator lets you search, view, download, archive, ordelete ColdFusion’s log files This page is shown in Figure 43-21:

Figure 43-21: The Log Files page.

This page enables you to keep track of ColdFusion’s log files by using a slick graphical face This feature is enabled only for ColdFusion MX Enterprise; if you are using Professional,your only option is to open the log files and view them in a text editor or build a customapplication to view them Next to each log file are icons for the following four actions (Theseare listed from left to right):

Trang 9

inter-✦ Search/View: This icon takes you to the log-file viewer, where you can search the log

files or browse through them to look at all the messages

✦ Download: This option downloads the log file to your machine for offsite analysis.

✦ Archive: This option copies the log file to an archive file and clears the original log.

The archive file is named logfilename.log.x, where x is the number of the log file,

with 1 the most recent

✦ Delete: This option deletes the log file entirely.

Scheduled Tasks

The Scheduled Tasks page of ColdFusion Administrator tells ColdFusion when and how toexecute certain ColdFusion templates on a schedule This page is shown in Figure 43-22:

Figure 43-22: The Scheduled Tasks page.

Normally, a ColdFusion template executes after a user requests the template with a browser

But you can also schedule a template to execute at a specific time That’s where the

Scheduled Tasks page comes in

Setting up a scheduled task involves the following parameters:

✦ Task Name: Enter an easily identifiable name for the task in this field, as you use this

name to refer to the task in your scheduled-tasks logs

✦ Duration: This setting consists of a Start Date and an optional End Date Some

confu-sion surrounds these values, because some people think that ColdFuconfu-sion begins therequest on the start date and ends the request on the end date This is not the case; the

value that you enter in the Start Date field is when ColdFusion starts scheduling the

task, and the value in the End Date field is when ColdFusion stops scheduling the task

Trang 10

✦ Frequency: You can select among the following three types of scheduling frequency:

• One Time: As the name indicates, this task is executed only once, at the specified

time

• Recurring: You can execute the task once a day, once a week, or once a month, at

the specified time If the task recurs daily, the task is executed every day at thespecified time If the task recurs weekly, the task executes on the same day of theweek as the start date, at the specified time If the task recurs monthly, the taskexecutes on the same day of the month as the start date, at the specified time

• Daily every: This option may seem confusing because you have a Daily option for

Recurring, but they do two different things This Daily executes the task over a

repeating interval; you could, for example, execute a task every hour from 12 a.m

to 12 p.m The Start Time and End Time in this section indicate the time of thefirst execution and the time when execution stops for the given day, respectively

✦ URL: As you’ve probably guessed, this field is where you enter the URL of the template

that’s to execute This value cannot be an https:// URL, as CFSCHEDULE currentlydoes not support SSL

✦ Username and Password: Use these parameters if the page requires basic authentication.

✦ Timeout (sec): Enter here the number of seconds to wait for a response from the server

before considering the task “failed” and throwing an error

✦ Proxy Server: If a proxy server is used, specify its address and port number here.

✦ Publish: If this option is enabled, the output from the scheduled task is saved to the file

named in the File field

✦ File: See the previous option for information.

✦ Resolve URL: If Publish is enabled, all links in the scheduled task’s output are resolved

into a fully qualified URL before the content is written to the file

System Probes

The System Probes page of ColdFusion Administrator (shown in Figure 43-23) tells ColdFusionwhen and how to execute system probes to diagnose the health of your ColdFusion Server

System probes check the “heartbeat” of your ColdFusion server and report back to you if the

heartbeat cannot be detected A system probe is a template that ColdFusion executes at a

reg-ular interval, much as it does a scheduled task The difference is that, every time thatColdFusion executes a probe, it does the following two things:

✦ ColdFusion marks the probe as either successful or failed depending on the result ofexecuting the probe — more on this later in this section

✦ If the probe fails, ColdFusion sends an e-mail to the site administrator telling him thatthe probe failed and exactly how it failed

The following three things cause a probe to fail:

✦ ColdFusion cannot connect to the probe template to execute it, either because the pagedoes not exist or the Web server is down

Trang 11

✦ ColdFusion does not receive a 200-success code from the probe template See theEnable HTTP Status Codes option in the section “Settings” earlier in this chapter, formore information.

✦ The probe constraint defined within Administrator fails You can set up the probe sothat it looks for a particular string or regular expression within the output returnedfrom the probe and fails depending on whether the string is found

Figure 43-23: The System Probes page.

If the probe does fail, you can e-mail the site administrator and/or execute an externalprogram

Code Analyzer

The Code Analyzer was included with ColdFusion MX as an assistant to developers upgradingfrom earlier versions of ColdFusion It can find code that results in an error in MX, such asthe old Oracle maxrows technique and problems using QueryNew() You point the ColdAnalyzer to the directory containing your source code by entering its path in the Directory

to Analyze field, and the Code Analyzer parses and analyzes all your code This page is shown

in Figure 43-24:

Unfortunately, the Code Analyzer can’t detect all the problems with your code, so don’t justrun a quick report and tell your client, “We’re good to go” because you probably have lots ofdetailed migration work to do The only real way to analyze your code for migration is tofirst perform this basic Code Analyzer run-through, resolve any issues that it spots, and thenperform full formal regression and load tests on the code that is running on an MX stagingserver

Trang 12

Figure 43-24: The Code Analyzer page.

<applet name=”TickerApplet” code=”sText”

codebase=”http://localhost/classes/” width=”350” height=”20”

hspace=”20”>

<param name=”background” value=”000000”>

<param name=”data” value=”http://localhost/ticker.txt”>

<param name=”defaultMessage” value=”Please wait ”>

<param name=”defaultURL” value=”http://localhost/index.cfm”>

Trang 13

<param name=”font” value=”Arial”>

<param name=”foreground” value=”FFFFFF”>

<param name=”frame” value=”_blankLoad”>

<param name=”highlite” value=”FF0000”>

<param name=”pause” value=”2”>

<param name=”refresh” value=”2”>

<param name=”size” value=”12”>

<param name=”wait” value=”3000”>

</applet>

Figure 43-25: The Java Applets page.

Instead, by using this option, you can write the same code as follows:

<cfapplet appletsource=”Ticker” name=”TickerApplet”>

From the main page, you can register a new applet or modify an existing registration Bothoptions take you to the applet configuration page, which contains the following options:

✦ Applet Name: This field is where you enter a short alias for your applet.

✦ Code: This field is where you enter is the name of the class file without the

exten-sion Don’t specify a path

✦ Code Path: This field is for the URL of the directory containing the class file or for

the JAR file containing the class file

✦ Archive: If the class file is stored in a JAR file, this filed is where you enter the name

of the JAR file Otherwise, leave this field blank

✦ Method: If the applet is intended for use as a form control, the applet should expose a

method that returns a single string; ColdFusion uses this string as the field value that issubmitted to the action page This field contains the name of the method that returnsthis single string value

✦ Height: The default height of the applet goes in this field.

✦ Width: The default width of the applet goes in this field.

✦ VSpace: The default amount of space above and below the applet when the applet is

rendered in a user’s browser goes in this field

Trang 14

✦ HSpace: The default amount of space to the left and right of the applet when the applet

is rendered in a user’s browser goes in this field

✦ Align: The default alignment of the applet goes in this field.

✦ Not Supported Message: If the user’s browser doesn’t support Java, he sees the

mes-sage that you enter in this instead of the applet itself

✦ Applet Parameters: These fields are for any default parameters that should be passed

to the applet

If your code calls CFAPPLET by using one or more of the parameters in these last fields, theparameters given in the CFAPPLET tag take precedence over the configurations you setup inColdFusion Administrator

CFX Tags

This page enables you to register CFX tags, which are custom tags written in Java or C++

instead of CFML The setup parameters for each type of tag are different, so we discuss themseparately in the following sections

C++ CFX Tags

C++ tags are easier to set up than their Java counterparts After you click Register C++ CFX oredit an existing one, you see the interface shown in Figure 43-26:

Figure 43-26: The C++ CFX Tags page.

The C++ CFX Tag registration page contains the following five parameters:

✦ Tag Name: Must begin with CFX_ This is the name of the tag referenced in your

ColdFusion code

✦ Server Library (.dll): This is the full path and file name of the tag’s DLL.

✦ Procedure: This is the name of the function to call within the DLL after the CFX tag is

called This is almost always ProcessTagRequest unless the same DLL is used for tiple CFX tags

mul-✦ Keep Library Loaded: If this option is enabled, ColdFusion does not release the DLL

after calling the tag the first time so that ColdFusion doesn’t need to allocate memoryfor the tag more than once This has the side effect of locking the DLL until theColdFusion Server service is cycled, so disable this option during development butenable it during production

✦ Description: A short description of the tag.

Trang 15

Java CFX Tags

Java CFX Tags use fewer parameters than their C++ counterparts, but the setup process ismore extensive The interface for creating a Java CFX tag is shown in Figure 43-27:

Figure 43-27: The Java CFX Tags page.

As for C++ CFX tags, the process begins on the CFX Tags page of Administrator After you clickRegister Java CFX or edit an existing one, you must supply the following three parameters:

✦ Tag Name: Must begin with CFX_ This is the name of the tag referenced in your

ColdFusion code

✦ Class Name: The name of the Java class to invoke This class name must be accessible

from the Java classpath defined in the Java and JVM settings

✦ Description: A short description of the tag.

After you register the tag, you must ensure that the class file is accessible fromColdFusion’s classpath, as defined on the Java and JVM page of Administrator Suppose, forexample, that if your class file is at the following location:

c:\classes\myTag.classColdFusion’s classpath must then include c:\classes\, and you would define the classname on the registration page as myTag Suppose, on the other hand, that your class file isstored in the following location:

Custom Tag Paths

The Custom Tag Paths page of ColdFusion Administrator (shown in Figure 43-28) is where youtell ColdFusion how to find commonly-used custom tags

By default, only one shared custom tag directory (located at cf_root/CustomTags) is defined

for ColdFusion Server You can use this page, however, to add additional shared tag paths.For information on using custom tags and how these shared paths are used, see Chapter 18

Trang 16

Figure 43-28: The Custom Tag Paths page.

CORBA Connectors

In this section, we’ll discuss CORBA Connectors Figure 43-29 shows the CORBA ConnectorsPage

Figure 43-29: The CORBA Connectors page.

This page is where you set up CORBA connectors for use with Borland’s VisiBroker To get tothis page in ColdFusion Administrator, click CORBA Connectors in the Extensions section ofColdFusion Administrator’s navigation bar To set up the VisiBroker connector, follow thesesteps:

1 Click Register CORBA Connector.

2 Enter a name for the connector in the ORB Name field (We use VisiBroker.)

3 Enter coldfusion.runtime.corba.VisibrokerConnector in the ORB Class Name

field

4 Leave the Classpath field blank and enter cf_root/lib/vbjorb.properties in

the ORB Property File field (replacing cf_root with the root of your ColdFusion

installation)

5 Click Submit.

6 Open vbjorb.properties inside of C:\CFusionMX\lib and edit the SVCnameroot property

so that ColdFusion can find the root (This assumes that you are familiar with CORBA.)Restart ColdFusion Server after adding the CORBA connection

Trang 17

In this chapter you learn the basics of how to use ColdFusion Administrator Every setting

is covered, and you learn some details about setting up ColdFusion Server for bestperformance

This chapter is intended only as a general overview of ColdFusion Administrator and todescribe some of its options The following chapter focuses more on configuration details,sandbox/resource security measures, and better performance

Trang 18

Configuration Tips and Tricks

The preceding chapter gave you an overview of the settings inColdFusion Administrator, but some things warrant more discus-sion, such as caching settings and sandbox security This chapter isgeared more toward configuration for performance and security and

is intended for someone already familiar with the basics ofColdFusion Administration

Choosing the Number of Simultaneous Request Threads

How many simultaneous request threads should you choose? Thisquestion is one of the most common that’s asked about ColdFusiontuning and configuration Unfortunately, we can give you no hard-and-fast answer Whether this number should be five, fifty, or something

in between (or even more) can be determined only by a formal loadtest of your application using a commercial-grade testing suite (Refer

to Chapter 43 for a discussion of what request threads are.)

To determine this optimum number of simultaneous requests, followthese steps (This assumes you are already in the Settings page ofColdFusion Administrator):

1 Start with five simultaneous requests (request threads) and run

a comprehensive test scenario at high load

2 Double the number of request threads to 10 and rerun the

same test scenario at the same load

3 Compare the full compliment of performance metrics recorded

in your test, but pay particular attention to minimum, mum, and average response times and the standard deviationfor response times Keep your eye on RAM and CPU usage todetermine whether you get a nonlinear jump in values

maxi-4 Double the number of request threads to 20 and rerun

every-thing else exactly the same as before

How do your metrics look now? Are they still responding in afairly linear fashion with a fast response time?

Trang 19

5 If so, keep this cycle up, doubling the number of threads with each retest and recheck

of your metrics Keep the cycle up until response times become erratic (that is, thestandard deviation grows very large) or slow or your RAM and CPU usage jumpsharply After this jump happens, you want to back off in the opposite direction, asdescribed in Step 6

6 In ramping down, start by taking the difference between the first “failed” setting for

the number of simultaneous requests and the previous run, dividing that difference

by two and adding it to the previous run’s value If the previous run used 20 threadsand the first failed run used 40, for example, the next run should use 30, calculated as

20 + ((40 - 20) / 2)

7 If this “ramped-down” test yields successful performance metrics, scale it back up by

half In the example in the preceding step, this new value would be 35, calculated as

30 + ((40 - 30) / 2)

8 Continue ramping back and forth (aka hopscotching) until your test performance metrics

yield the best results

But believe it or not, you’re not finished! The number of simultaneous request threads is onlyone setting that affects and is affected by many other settings in ColdFusion MX, your Webserver, your database server, and even your operating system and hardware In reality, allthese factors must be balanced like the old Chinese Spinning Plate Trick — not an easy thing

to do even with the best of training

A general guideline, however, is that you don’t want to set this number too low or requestsqueue up and negatively affect the performance of your site, and you don’t want to set thisnumber too high because that uses up too many resources on your server and causes mem-ory to constantly page to disk, which also negatively affects performance

Caching

Developers frequently ask how many templates they should set ColdFusion to cache in RAM.The simple answer is “as many as possible.” The more templates that ColdFusion can store inits cache, the less ColdFusion must access the hard drive to execute code If memory is at apremium on your server, however, you should probably scale this number back to giveColdFusion room to breathe

In an ideal environment, you would take the total number of ColdFusion templates in yourWeb site, multiply that number by 1.25, and then use that as the size of your template cache.This formula makes sure that you have room for all your templates in the cache and alsogives you a little breathing room in case you add more templates

Cache size in ColdFusion MX is a different unit of measure from earlier versions of ColdFusionServer, which measured cache size in kilobytes ColdFusion MX measures the cache size in thenumber of templates instead

You can also speed up the cache even more by turning on the Trusted Cache feature (Trusted

Cache is available in the Caching page of ColdFusion Administrator.) This option tellsColdFusion to “trust” whatever is already cached and not to waste a single millisecond check-ing to determine whether a file has been updated We always turn on this option on our pro-duction servers, and we always turn it off on our development servers A side-effect ofenabling this option is that you must restart the ColdFusion service for ColdFusion to recog-nize changes to the source code

Note

Trang 20

Chart caching

ColdFusion MX also adds options for caching charts (generated by calls to CFCHART) First,you can specify whether the chart cache is stored in memory or on disk (with disk cachingthe default) If you have the RAM to spare, use in-memory caching to speed your server’s per-

formance If, on the other hand, you either don’t have much RAM or you do a lot of charting,

choose disk caching to save memory

Choosing the maximum number of images in the cache differs depending on whether you’redoing disk caching or memory caching If using memory caching, keep this number relativelylow so that you don’t end up using all your memory for chart caching If using disk caching,make this number as high as feasible because you are limited only by the amount of freespace on your hard drive

Query caching

Query caching is another one of those parameters that you can’t truly set until you load-test

your application by using a commercial-grade load-testing tool and production-scale test

data (This parameter is set on the Caching page of ColdFusion Adminstrator.) You can’t tellhow large or varied your queries may be until you perform such a test, and these two factors(variance and scale) completely dominate the number of queries that you should setColdFusion Server to cache in its memory

You should set this parameter only after you set parameters for JVM memory usage, templatecache size, and simultaneous requests — in that order Start with a very low number such asfive and run a high load-test scenario with the maximum number of virtual users that youexpect your system to handle (a very important test, especially if you exhaust a lot of yourmemory through heavy use of the Session scope) Your watchpoints are response timings(minimum, maximum, average, and standard deviation) and available physical memory

If you adjust this parameter, but your application’s response time doesn’t improve cantly, make sure that you are making effective use of query caching in your code

signifi-If you do receive a significant benefit from increasing the number of cached queries, use thehopscotching method that we describe in the section “Choosing the Number of SimultaneousRequest Threads,” earlier in this chapter, to balance available physical memory with

response times If you do so, you eventually set the right number Remember that a largestandard deviation on response times indicates erratic behavior, so back off if you see thisvalue jump sharply

Using a UUID For CFTOKEN

Using a UUID for CFTOKEN is a security precaution (You can find this option on the Settingspage of ColdFusion Administrator.) By default, ColdFusion uses an eight-digit random numberfor the value of CFTOKEN, making it relatively easy to guess Enabling this option makesColdFusion use a UUID with a random 12-digit hexadecimal number prepended as CFTOKEN

This modified UUID is impossible to guess, removing any possibility of a user hacking intoanother user’s session by manipulating the values of CFID and CFTOKEN in URL

It’s always a good idea to use a UUID for CFTOKEN It’s usually not a concern on developmentservers (although it certainly won’t hurt), but on a production server, always considerenabling this option

Trang 21

Using J2EE Session Variables

By default, ColdFusion MX doesn’t use J2EE session management and opts instead to identify auser’s Session variables through the combination of CFID and CFTOKEN sent by each of hisbrowser requests Enabling J2EE Session variables makes ColdFusion forego CFID and CFTOKENfor session management purposes and instead use J2EE’s native session-management mecha-nism (You can find this option in the Memory Variables page of ColdFusion Administrator.)With J2EE Session variables enabled, your ColdFusion MX application can share Session,Application, and Request variables with JSP pages and other J2EE applications running on thesame server

For more information on J2EE session management, see Chapter 19 (You must restartColdFusion server for this setting to take effect.)

Datasources

If you’re using a database server rather than a file-based database such as Microsoft Access,you want to use an IP address rather than a host name or computer name in specifying yourdatabase server Using the host name requires ColdFusion to perform a DNS lookup beforeconnecting to the database server, and using a computer name means doing a networklookup Using an IP address enables ColdFusion to connect to the database server directly.After setting up and verifying your datasource with a correct username and password tomake sure that you can connect to your database, edit the datasource definition and removethe username and password (See the Data Sources section in Chapter 43 for information onverifying and editing datasources.) Instead, store the username and password in Requestvariables defined in Application.cfm or a similar mechanism and pass them in every call toCFQUERYand CFSTOREDPROC Doing so takes the username and password out of ColdFusionMX’s XML properties files and puts the connection information in Application.cfm tem-plates, which are easier to secure

A datasource’s connection settings define how ColdFusion connects to the database serverand which database it uses You also have advanced settings, however, that, if used correctly,can really enhance your application’s performance Table 44-1 describes these advancedsettings:

Table 44-1: Advanced Datasource Parameters

Parameter Name Description

Connection String If a database driver accepts connection strings, you can provide any

additional connection parameters in the form of a connectionstring provided in this parameter

Limit Connections If this option is enabled, ColdFusion limits the number of

simultaneous database requests according to the number provided

in the setting for Restrict Connections To

Restrict Connections To See the description of the preceding parameter for information.Maintain Connections If this parameter is enabled, ColdFusion connects to the datasource

once for a given client instead of reconnecting on every request.See Timeout (min) and Interval (min) for more information

Trang 22

Parameter Name Description

Timeout (min) If you are maintaining connections and the time between a client’s

requests is greater than this number of minutes, ColdFusionexpires the cached connection

Interval (min) If you are maintaining connections, ColdFusion checks every x

number of minutes for expired connections

Disable Connections If this option is enabled, no application can use this datasource

Login Timeout (sec) In connecting to a database, ColdFusion waits this number of

seconds before timing out the attempt and throwing an error

CLOB Enabling this option enables ColdFusion to retrieve the entire

contents of a CLOB field (meaning a Memo field in Access or a Textfield in Microsoft SQL Server) Don’t enable this parameter unlessyou are absolutely sure that you need it, as this option causes alarge performance hit

BLOB Enabling this option enables ColdFusion to retrieve the entire

contents of a BLOB field (meaning an Image field in Microsoft SQLServer) Don’t enable this parameter unless you are absolutely surethat you need it, as this option causes a large performance hit

Long Text Buffer If CLOB retrieval is disabled, ColdFusion retrieves a maximum of

this number of characters from a CLOB, Memo, or Text field andtruncates the rest The default is 64,000 characters

Blob Buffer If BLOB retrieval is disabled, ColdFusion retrieves a maximum of

this number of bytes from a BLOB or Image field and truncates therest The default is 64,000 bytes

Allowed SQL This set of check boxes enables you to choose the SQL statements

that can be executed through this datasource, enabling you torestrict what applications can do

Select Method This option exists only for SQL Server and Sybase datasources The

value can be either Direct, meaning to use a standard client-sideretrieval (fine for nearly all users), or Cursor, meaning to use aserver-side cursor (only for advanced developers) Don’t changethis option unless you have a compelling reason to do so

Trusted Connection This option exists only for ODBC socket datasources A trusted

connection implies that, instead of using a username andpassword to access a database, the connection uses the name ofthe currently logged in user to connect Using a Trusted Connectionimplies a Windows network and currently works only for MicrosoftSQL Server

Java and JVM Settings

The Java and JVM settings section of Administrator tells ColdFusion how to use the JavaVirtual Machine (JVM) Naturally, these settings are rather sensitive and the defaults should

be acceptable for most users Modify these settings only if you have a compelling reason to

do so

Trang 23

The Java Virtual Machine path tells ColdFusion where to find the Java Virtual Machine DLL(jvm.dll on Windows or jvm.so on Solaris) Don’t modify this parameter unless the JVMlocation changes.

Adjusting the Initial Memory Size and Maximum Memory upward is probably a good idea ifyou have the RAM to do so The default maximum is 512MB, but don’t set the maximum anylower than 32MB because ColdFusion may not be able to start up again These settings con-trol how much memory Java can allocate to ColdFusion

Our suggestion is to leave the Initial Memory Size value blank so that the JVM is unrestrictedduring ColdFusion startup, but explicitly specify a Maximum Memory value as large as yourhardware, operating system, and other software requirements enable One good indicator forhow much you can safely increase the Maximum Memory value is the Available PhysicalMemory value that you should be measuring during your load tests Consider increasing yourJVM’s Maximum Memory value if you still have RAM to spare during your load tests

The Classpath setting tells Java where to look for Java classes This is a comma-delimited list

of directories, JAR files, and/or ZIP files where ColdFusion looks for Java class files Theonly reason that you would need to modify this parameter is if you are using a custom Javaextension such as a Java-based CFX custom tag or JSP tag library

Sandbox and Resource Security

Sandbox/Resource Security is probably one of the best new features in the MX release ofColdFusion Server Before MX, ColdFusion Server used a tool called Advanced Security thatwas notoriously unreliable and difficult to use — so much so that it is no longer supported inColdFusion MX Because it is built on Java, MX can make use of J2EE Sandbox Security, which

is easy to use and configure and works remarkably well

We should note the difference between Sandbox security and Resource security The two are

often used interchangeably, but they really shouldn’t be Sandbox Security is available only inColdFusion MX Enterprise and enables you to define different security settings for differentdirectories on your server ColdFusion MX Professional offers a version known as ResourceSecurity, which enables you define similar security settings, but they apply for the entire server.This chapter describes Enterprise’s Sandbox Security; Resource Security is virtually identical

To access Sandbox Security, log in to ColdFusion Administrator and click the SandboxSecurity link at the bottom of the left bar Before you can use Sandbox Security, you mustenable it by selecting the check box on the main Sandbox Security page Restart theColdFusion Application Server service after enabling Sandbox Security

To define a security sandbox, choose the directory containing the files that you want tosecure in the Add Security Sandbox section You can either create a new sandbox or copy anexisting one by using the drop-down list After you click Add, the new sandbox appears in thelist of active sandboxes Click Edit to modify the security settings

Five pages in the Sandbox Security editor correspond to the five resources that you canrestrict: Data Sources, CF Tags, CF Functions, Files and Directories, and Servers and Ports.The following sections describe each of these pages

Data Sources

The first page of the Sandbox Security editor enables you to choose the datasources that theapplication that runs in a sandbox directory can access The data sources are presented in a

familiar chooser interface, where you have a list of Enabled Data Sources, a list of Disabled Data

Sources, and buttons to move data sources between the two lists, as shown in Figure 44-1

Trang 24

Figure 44-1: The Data Sources page of the Sandbox

Security editor

<<ALL DATASOURCES>>may seem rather confusing; after all, not all datasources must be onthe same side of the chooser interface Think of <<ALL DATASOURCES>> as a placeholder fornew datasources; if <<ALL DATASOURCES>> is disabled, any new datasources created afterthe sandbox is configured are also disabled

CF Tags

The second page of the Sandbox Security editor enables you to disable access to ColdFusionTags that may be dangerous, such as CFOBJECT or CFREGISTRY As is the Data Sources page,the CF Tags are presented in a chooser, as shown in Figure 44-2

Figure 44-2: The CF Tags page of the Sandbox

Security editor

Always disable tags that aren’t to be used in a particular application, because they tend topresent a security hole Make sure that you don’t enable CFOBJECT unless really necessary,because CFOBJECT can invoke destructive code through a COM or Java object on your server

If you use CFCs, however, you may need to enable CFOBJECT

Part IV of this book describes CFCs, or ColdFusion Components, in detail

Trang 25

Figure 44-3: The CF Functions page of the Sandbox

Security editor

Disable CreateObject() unless you’re sure that it’s going to be used, such as to instantiateColdFusion components

Files and Directories

The Files and Directories page enables you to granularly control who can access what files onyour system By default, code in a sandbox can access files in the sandbox directory and itssubdirectories but cannot access any files outside the sandbox

The Files and Directories page interface is shown in Figure 44-4

Figure 44-4: The Files and Directories page of the Sandbox

Security editor

To grant the sandbox permissions on a directory that isn’t already part of the current box, follow these steps:

sand-1 Enter the path to the file or directory or choose the path by using the Browse Server

button To grant permissions on a directory and all files and subfolders in that

direc-tory, put a /* after the directory name To grant permissions on a directory and sively apply those permissions to all files and subfolders of the directory, no matter

recur-how deeply nested, put a /- after the directory name

Trang 26

2 Choose the permissions to enable for that directory Be especially careful of enabling

both write and execute access on the same directory, as this could lead to maliciousprograms getting executed on your server

3 Click Add Files / Paths.

Use the same basic technique to edit existing permissions by first clicking the item that youwant to edit in the Secured Files and Directories list and then editing the permissions andclicking Edit Files / Paths

Servers and Ports

The last page of the Sandbox Security editor enables you to restrict an application’s access tooutside resources This page’s interface is similar to the one used for Files and Directories,and is shown in Figure 44-5

Figure 44-5: The Servers and Ports page of the Sandbox

Security editor

To give an example, say that the application in the sandbox that you’re configuring uses thefollowing calls to outside systems:

✦ CFHTTP to quote.yahoo.com on port 80

✦ CFLDAP to ldap.four11.com on any port

✦ CFFTP with ftp.somewhere.com on any port between 15 and 21

These three servers are the only ones that this sandbox should have access to, because youcertainly don’t want some rogue developer establishing a CFFTP session with

ftp.wegotviruses.comand infecting the entire server!

As an example of using the Servers and Ports, follow these steps to configure the three serverand port configurations from the preceding list:

1 Enter quote.yahoo.com in the Server/IP Address field and 80 in the Port field and then

click Add IP Address

2 Put ldap.four11.com in the Server/IP Address field but leave the Port field blank

(because you don’t want to restrict by port) and then click Add IP Address again

Trang 27

3 Put ftp.somewhere.com in the Server/IP Address field In the Port field, enter 15-21

and, before clicking Add IP Address, select the Port Range radio button next to the Portfield to tell ColdFusion that you are entering a range rather than a single port number.Table 44-2 describes the standard ports used with ColdFusion’s Internet Protocol tags

Table 44-2: Standard Port Assignments for ColdFusion’s Networking Tags

Tag Standard Port (see www.iana.org/assignments/port-numbers for

a list of all standard port assignments)

We have specifically avoided giving advice such as “set this parameter to this number” or

“always set your configuration this way” because everyone’s server is different, and noparameter can be set in isolation from the others As we state near the end of the section

“Choosing the Number of Simultaneous Request Threads,” earlier in this chapter

“[Each parameter] is only one setting that affects and is affected by many other settings in ColdFusion MX, your Web server, your database server, and even your operating system and hardware In reality, all these factors must be balanced like the old Chinese Spinning Plate Trick — not an easy thing to do even with the best of training.”

The only way to verify your settings is as a complete server configuration rather than an vidual setting — and then only in a production environment The only way to estimate yourconfiguration in advance of deploying to your production environment is by using a commer-cial-grade load-testing tool Anything else is just guessing, and guessing is never good enough.After you have everything tuned to perfection, you can use ColdFusion’s Archive and Deployfeature to ensure that your settings are deployed along with your application (Note thatArchive and Deploy is only available in ColdFusion MX Enterprise.)

Trang 28

Chapter 46

Designing YourApplication Framework

Trang 30

Introduction to the Language Reference

We’ve always found the language references in most computerbooks to be useless wastes of space They are typically abbre-viated to the point of being cryptic; they give no real examples ofhow the language is used; and they are organized alphabetically

Either that or they are nothing more than mirrors of the standard erences that you receive with the software

ref-Until writing one ourselves we didn’t understand why languageguides turn out that way If we wrote the kind of language referencefor ColdFusion MX that we really want to, it would have a page count

larger than the entire ColdFusion MX Bible that you are reading now.

That approach doesn’t work for the publisher, who has a realisticpage count within which to work; nor does it work for the printer,who can physically bind only so many pages into a single book; nordoes it work for you, the reader, who doesn’t want to spend morethan $100 for a book about ColdFusion MX

We were told to keep the language reference relatively brief because

of these page limits So we can’t show example code for tags, as

Macromedia’s 738-page CFML Reference does Our mandate is to

impart as much practical knowledge as is possible in a very smallspace Here goes

How This Language Reference

is Organized

We decided to do things differently from all other ColdFusion ences in organizing this language reference We’ve turned it into asolutions-oriented guide to the CF MX language, designed to workhand-in-hand with the language implementation techniques detailed

refer-in Part III, “The ColdFusion MX Language.” This language referenceshows language syntax and important usage notes, and Part IIIdescribes how everything fits together in the real world

First, we grouped all tags and functions into their most familiar gories according to how they are thought of in real-world develop-ment Macromedia, for example, categorizes DateFormat() as adisplay function and Now() as a date function Putting these func-tions into separate categories may be true technically, but don’t youreally consider both these functions to be date-related? We do, and so

cate-do many new ColdFusion developers struggling to learn the language,

so we have grouped all functions that are most commonly used towork with dates and date-related issues under a common heading

45

Trang 31

Second, we didn’t separate tags from functions Why do this? Wouldn’t discussingQueryNew()alongside CFQUERY make better sense than separating them? We think so Now,whenever you have a language-related question about working with databases or the queriesthat they produce, you just flip to Chapter 52, and all the tags and functions that you need areright there in one place Seeing all the tags and functions related to a specific topic togethercan often inspire you to intelligently solve a problem by using tags and functions that younever before considered.

We didn’t, however, do away with alphabetizing tags and functions for quick reference As inthe case in traditional references, we include separate alphabetical listings of tags and func-tions in the following sections so that you can quickly find the reference for a specific item

We also separate tags and functions into their own alphabetical groups within each specific section in each chapter

topic-How to read the listings

Keep the following points in mind in reading through the language reference:

✦ To avoid confusion, if a tag or function has multiple forms of use, each is listed withonly the attributes used in that form

✦ If an attribute is required, its name appears in boldface

✦ If an attribute accepts one of a specific set of values, each is shown separated by a pipecharacter | and the default value is listed first Each specific value is listed in all caps

✦ We sometimes use long variable names that precisely describe their contents andpurpose

✦ We group related attributes in order to show how they work together

✦ We explicitly show where pound signs are needed around variables and where they arenot You use pound signs one way in looping over a collection, for example, andanother way in looping over a query object (See the listing for CFLOOP in Chapter 49for details.)

✦ We sometimes use actual values in place of variables if the resulting description ismore clear and straightforward The value of the applicationTimeout attribute of theCFAPPLICATIONtag, for example, is simply #CreateTimeSpan(2,0,0,0)# rather than

#CreateTimeSpan(days, hours, minutes, seconds)#, because the former is veryclose to what you may typically use, and we’re not trying to explain how

CreateTimeSpan()works

✦ In listing a function, we boldface the data type returned

✦ We list only those tags and functions that are operable in ColdFusion MX

We hope that you like your Language Reference!

Alphabetical Listing of Tags

The following alphabetical listing of tags will help you quickly find the reference for a tagwhose name you already know Just find the tag in the following list and go to the chaptershown to the right of the tag Each chapter separates tags and functions into separate groupsthat are alphabetically listed Some chapters are broken into topic-specific sections, whereeach section is separately alphabetized

Trang 32

CFABORT (Ch 49)CFAPPLET (Ch 55, Java, COM, and CORBA)CFAPPLICATION (Ch 46)

CFARGUMENT (Ch 63)CFASSOCIATE (Ch 53)CFBREAK (Ch 49)CFCACHE (Ch 47, General)CFCASE (Ch 49)

CFCATCH (Ch 50)CFCHART (Ch 59, Charting)CFCHARTDATA (Ch 59, Charting)CFCHARTSERIES (Ch 59, Charting)CFCOL (Ch 52)

CFCOLLECTION (Ch 57)CFCOMPONENT (Ch 63)CFCONTENT (Ch 60, On the Client(User’s) Computer)

CFCOOKIE (Ch 48, General)CFDEFAULTCASE (Ch 49)CFDIRECTORY (Ch 60, On ColdFusionServer)

CFDUMP (Ch 48, General)CFELSE (Ch 49)

CFELSEIF (Ch 49)CFERROR (Ch 50)CFEXECUTE (Ch 55, Operating System)CFEXIT (Ch 53)

CFFILE (Ch 60, On ColdFusion Server)CFFLUSH (Ch 56, Server Output)CFFORM (Ch 51)

CFFTP (Ch 60, On an FTP Server)CFFUNCTION (Ch 63)

CFGRAPH (Ch 59, Charting)CFGRAPHDATA (Ch 59, Charting)CFGRID (Ch 51)

CFGRIDCOLUMN (Ch 51)CFGRIDROW (Ch 51)CFGRIDUPDATE (Ch 51)CFHEADER (Ch 47, General)CFHTMLHEAD (Ch 56, Server Output)CFHTTP (Ch 55, Web Servers)CFHTTPPARAM (Ch 55, Web Servers)CFIF (Ch 49)

CFIMPORT (Ch 55, Java, COM, and CORBA)CFINCLUDE (Ch 47, General)

CFINDEX (Ch 57)CFINPUT (Ch 51)CFINSERT (Ch 52)CFINVOKE (Ch 63)CFINVOKEARGUMENT (Ch 63)CFLDAP (Ch 62, Authentication andAuthorization)

CFLOCATION (Ch 49)CFLOCK (Ch 48, General)

CFLOG (Ch 59, Logging)CFLOGIN (Ch 62, Authentication andAuthorization)

CFLOGINUSER (Ch 62, Authenticationand Authorization)

CFLOGOUT (Ch 62, Authentication andAuthorization)

CFLOOP (Ch 49)CFMAIL (Ch 58)CFMAILPARAM (Ch 58)CFMODULE (Ch 53)CFOBJECT (Ch 55, Java, COM, andCORBA; and Ch 63)

CFOBJECTCACHE (Ch 52)CFOUTPUT (Ch 47, General & Ch 52)CFPARAM (Ch 48, General)

CFPOP (Ch 58)CFPROCESSINGDIRECTIVE (Ch 56,Whitespace)

CFPROCPARAM (Ch 52)CFPROCRESULT (Ch 52)CFPROPERTY (Ch 63)CFQUERY (Ch 52)CFQUERYPARAM (Ch 52)CFREGISTRY (Ch 61)CFREPORT (Ch 59, Reporting)CFRETHROW (Ch 50)

CFRETURN (Ch 63)CFSAVECONTENT (Ch 56, Server Output)CFSCHEDULE (Ch 47, General)

CFSCRIPT (Ch 54)CFSEARCH (Ch 57)CFSELECT (Ch 51)CFSERVLET (Ch 55, Java, COM, and CORBA)CFSERVLETPARAM (Ch 55, Java, COM,and CORBA)

CFSET (Ch 48, General)CFSETTING (Ch 56, Whitespace)CFSILENT (Ch 56, Whitespace)CFSLIDER (Ch 51)

CFSTOREDPROC (Ch 52)CFSWITCH (Ch 49)CFTABLE (Ch 52)CFTEXTINPUT (Ch 51)CFTHROW (Ch 50)CFTRACE (Ch 59, Logging)CFTRANSACTION (Ch 52)CFTREE (Ch 51)CFTREEITEM (Ch 51)CFTRY (Ch 50)CFUPDATE (Ch 52)CFWDDX (Ch 55, WDDX)CFXML (Ch 55, XML)

Trang 33

Alphabetical Listing of Functions

The following alphabetical listing of functions will help you quickly find the reference for afunction whose name you already know Just find the function in the following list and go tothe chapter shown to the right of the function Each chapter separates tags and functionsinto separate groups that are alphabetically listed Some chapters are broken into topic-specific sections, where each section is separately alphabetized

Abs() (Ch 48, Basic Math)ACos() (Ch 48, Geometry andTrigonometry)

ArrayAppend() (Ch 48, Arrays)ArrayAvg() (Ch 48, Arrays)ArrayClear() (Ch 48, Arrays)ArrayDeleteAt() (Ch 48, Arrays)ArrayInsertAt() (Ch 48, Arrays)ArrayIsEmpty() (Ch 48, Arrays)ArrayLen() (Ch 48, Arrays)ArrayMax() (Ch 48, Arrays)ArrayMin() (Ch 48, Arrays)ArrayNew() (Ch 48, Arrays)ArrayPrepend() (Ch 48, Arrays)ArrayResize() (Ch 48, Arrays)ArraySet() (Ch 48, Arrays)ArraySort() (Ch 48, Arrays)ArraySum() (Ch 48, Arrays)ArraySwap() (Ch 48, Arrays)ArrayToList() (Ch 48, Arrays)Asc() (Ch 48, ASCII)

ASin() (Ch 48, Geometry andTrigonometry)

Atn() (Ch 48, Geometry andTrigonometry)

BitAnd() (Ch 48, Binary Data)BitMaskClear() (Ch 48, Binary Data)BitMaskRead() (Ch 48, Binary Data)BitMaskSet() (Ch 48, Binary Data)BitNot() (Ch 48, Binary Data)BitOr() (Ch 48, Binary Data)BitSHLN() (Ch 48, Binary Data)BitSHRN() (Ch 48, Binary Data)BitXor() (Ch 48, Binary Data)Ceiling() (Ch 48, Numbers)Chr() (Ch 48, ASCII)CJustify() (Ch 48, Strings)Compare() (Ch 48, Strings)CompareNoCase() (Ch 48, Strings)Cos() (Ch 48, Geometry andTrigonometry)

CreateDate() (Ch 48, Dates and Times)CreateDateTime() (Ch 48, Dates andTimes)

CreateObject() (Ch 55, Java, COM,and CORBA; and Ch 63)

CreateODBCDate() (Ch 48, Dates andTimes)

CreateODBCDateTime() (Ch 48, Datesand Times)

CreateODBCTime() (Ch 48, Dates andTimes)

CreateTime() (Ch 48, Dates andTimes)

CreateTimeSpan() (Ch 48, Dates andTimes)

CreateUUID() (Ch 48, General)DateAdd() (Ch 48, Dates and Times)DateCompare() (Ch 48, Dates andTimes)

DateConvert() (Ch 48, Dates andTimes)

DateDiff() (Ch 48, Dates and Times)DateFormat() (Ch 48, Dates andTimes)

DatePart() (Ch 48, Dates and Times)Day() (Ch 48, Dates and Times)DayOfWeek() (Ch 48, Dates and Times)DayOfWeekAsString() (Ch 48, Datesand Times)

DayOfYear() (Ch 48, Dates and Times)DaysInMonth() (Ch 48, Dates andTimes)

DaysInYear() (Ch 48, Dates andTimes)

DE() (Ch 48, General)DecimalFormat() (Ch 48, Numbers)DecrementValue() (Ch 48, General)Decrypt() (Ch 62, Encryption)DeleteClientVariable() (Ch 48,General)

DirectoryExists() (Ch 60, OnColdFusion Server)

DollarFormat() (Ch 48, Numbers)Duplicate() (Ch 48, Structures)Encrypt() (Ch 62, Encryption)Evaluate() (Ch 48, General)Exp() (Ch 48, Geometry andTrigonometry)

ExpandPath() (Ch 60, On ColdFusionServer)

Trang 34

FileExists() (Ch 60, On ColdFusionServer)

Find() (Ch 48, Strings)FindNoCase() (Ch 48, Strings)FindOneOf() (Ch 48, Strings)FirstDayOfMonth() (Ch 48, Dates andTimes)

Fix() (Ch 48, Numbers)FormatBaseN() (Ch 48, Numbers)GetAuthUser() (Ch 62, Authenticationand Authorization)

GetBaseTagData() (Ch 53)GetBaseTagList() (Ch 53)GetBaseTemplatePath() (Ch 60, OnColdFusion Server)

GetClientVariablesList() (Ch 48,General)

GetCurrentTemplatePath() (Ch 60, OnColdFusion Server)

GetDirectoryFromPath() (Ch 60, OnColdFusion Server)

GetException() (Ch 50)GetFileFromPath() (Ch 60, OnColdFusion Server)

GetFunctionList() (Ch 47, System)GetHttpRequestData() (Ch 55, WebServers)

GetHttpTimeString() (Ch 48, Datesand Times)

GetK2ServerDocCount() (Ch 57)GetK2ServerDocCountLimit() (Ch 57)GetLocale() (Ch 47, System)GetMetaData() (Ch 63)GetMetricData() (Ch 47, System)GetPageContext() (Ch 47, System)GetProfileSections() (Ch 47, System)GetProfileString() (Ch 47, System)GetTempDirectory() (Ch 60, OnColdFusion Server)

GetTempFile() (Ch 60, On ColdFusionServer)

GetTemplatePath() (Ch 60, OnColdFusion Server)

GetTickCount() (Ch 48, Dates andTimes)

GetTimeZoneInfo() (Ch 48, Dates andTimes)

GetToken() (Ch 48, Lists)Hash() (Ch 62, Encryption)Hour() (Ch 48, Dates and Times)HTMLCodeFormat() (Ch 56, ServerOutput)

HTMLEditFormat() (Ch 56, ServerOutput)

IIf() (Ch 48, General)IncrementValue() (Ch 48, General)InputBaseN() (Ch 48, Numbers)Insert() (Ch 48, Strings)Int() (Ch 48, Numbers)IsArray() (Ch 48, Arrays)IsBinary() (Ch 48, Binary Data)IsBoolean() (Ch 48, General)IsCustomFunction() (Ch 54)IsDate() (Ch 48, Dates and Times)IsDebugMode() (Ch 47, System)IsDefined() (Ch 48, General)IsK2ServerABroker() (Ch 57)IsK2ServerDocCountExceeded() (Ch 57)IsK2ServerOnline() (Ch 57)

IsLeapYear() (Ch 48, Dates andTimes)

IsNumeric() (Ch 48, Numbers)IsNumericDate() (Ch 48, Dates andTimes)

IsObject() (Ch 48, General)IsQuery() (Ch 52)

IsSimpleValue() (Ch 48, General)IsStruct() (Ch 48, Structures)IsUserInRole() (Ch 62,

Authentication and Authorization)IsWDDX() (Ch 55, WDDX)

IsXmlDoc() (Ch 55, XML)IsXMLElem() (Ch 55, XML)IsXMLRoot() (Ch 55, XML)JavaCast() (Ch 55, Java, COM, andCORBA)

JSStringFormat() (Ch 48, Strings)LCase() (Ch 48, Strings)

Left() (Ch 48, Strings)Len() (Ch 48, Strings)ListAppend() (Ch 48, Lists)ListChangeDelims() (Ch 48, Lists)ListContains() (Ch 48, Lists)ListContainsNoCase() (Ch 48, Lists)ListDeleteAt() (Ch 48, Lists)ListFind() (Ch 48, Lists)ListFindNoCase() (Ch 48, Lists)ListFirst() (Ch 48, Lists)ListGetAt() (Ch 48, Lists)ListInsertAt() (Ch 48, Lists)ListLast() (Ch 48, Lists)ListLen() (Ch 48, Lists)ListPrepend() (Ch 48, Lists)ListQualify() (Ch 48, Lists)ListRest() (Ch 48, Lists)ListSetAt() (Ch 48, Lists)ListSort() (Ch 48, Lists)ListToArray() (Ch 48, Lists)

Trang 35

ListValueCount() (Ch 48, Lists)ListValueCountNoCase() (Ch 48,Lists)

LJustify() (Ch 48, Strings)Log() (Ch 48, Geometry andTrigonometry)

Log10() (Ch 48, Geometry andTrigonometry)

LSCurrencyFormat() (Ch 48, Numbers)LSDateFormat() (Ch 48, Dates andTimes)

LSEuroCurrencyFormat() (Ch 48,Numbers)

LSIsCurrency() (Ch 48, Numbers)LSIsDate() (Ch 48, Dates and Times)LSIsNumeric() (Ch 48, Numbers)LSNumberFormat() (Ch 48, Numbers)LSParseCurrency() (Ch 48, Numbers)LSParseDateTime() (Ch 48, Dates andTimes)

LSParseEuroCurrency() (Ch 48,Numbers)

LSParseNumber() (Ch 48, Numbers)LSTimeFormat() (Ch 48, Dates andTimes)

LTrim() (Ch 48, Strings)Max() (Ch 48, Basic Math)Mid() (Ch 48, Strings)Min() (Ch 48, Basic Math)Minute() (Ch 48, Dates and Times)Month() (Ch 48, Dates and Times)MonthAsString() (Ch 48, Dates andTimes)

Now() (Ch 48, Dates and Times)NumberFormat() (Ch 48, Numbers)ParagraphFormat() (Ch 56, ServerOutput)

ParameterExists() (Ch 48, General)ParseDateTime() (Ch 48, Dates andTimes)

Pi() (Ch 48, Geometry andTrigonometry)

PreserveSingleQuotes() (Ch 52)Quarter() (Ch 48, Dates and Times)QueryAddColumn() (Ch 52)

QueryAddRow() (Ch 52)QueryNew() (Ch 52)QuerySetCell() (Ch 52)QuotedValueList() (Ch 48, Lists)Rand() (Ch 48, Basic Math)Randomize() (Ch 48, Basic Math)

RandRange() (Ch 48, Basic Math)REFind() (Ch 48, Strings)REFindNoCase() (Ch 48, Strings)RemoveChars() (Ch 48, Strings)RepeatString() (Ch 48, Strings)Replace() (Ch 48, Strings)ReplaceList() (Ch 48, Strings)ReplaceNoCase() (Ch 48, Strings)REReplace() (Ch 48, Strings)REReplaceNoCase() (Ch 48, Strings)Reverse() (Ch 48, Strings)

Right() (Ch 48, Strings)RJustify() (Ch 48, Strings)Round() (Ch 48, Numbers)RTrim() (Ch 48, Strings)Second() (Ch 48, Dates and Times)SetEncoding() (Ch 47, System)SetLocale() (Ch 47, System)SetProfileString() (Ch 47, System)SetVariable() (Ch 48, General)Sgn() (Ch 48, Basic Math)Sin() (Ch 48, Geometry andTrigonometry)

SpanExcluding() (Ch 48, Strings)SpanIncluding() (Ch 48, Strings)Sqr() (Ch 48, Basic Math)StripCR() (Ch 56, Server Output)StructAppend() (Ch 48, Structures)StructClear() (Ch 48, Structures)StructCopy() (Ch 48, Structures)StructCount() (Ch 48, Structures)StructDelete() (Ch 48, Structures)StructFind() (Ch 48, Structures)StructFindKey() (Ch 48, Structures)StructFindValue() (Ch 48,

Structures)StructGet() (Ch 48, Structures)StructInsert() (Ch 48, Structures)StructIsEmpty() (Ch 48, Structures)StructKeyArray() (Ch 48, Structures)StructKeyExists() (Ch 48,

Structures)StructKeyList() (Ch 48, Structures)StructNew() (Ch 48, Structures)StructSort() (Ch 48, Structures)StructUpdate() (Ch 48, Structures)Tan() (Ch 48, Geometry and

Trigonometry)TimeFormat() (Ch 48, Dates andTimes)

ToBase64() (Ch 48, Binary Data)

Trang 36

ToBinary() (Ch 48, Binary Data)ToString() (Ch 48, Strings)Trim() (Ch 48, Strings)UCase() (Ch 48, Strings)URLDecode() (Ch 48, General)URLEncodedFormat() (Ch 48, General)URLSessionFormat() (Ch 46)

Val() (Ch 48, Numbers)ValueList() (Ch 48, Lists)Week() (Ch 48, Dates and Times)

WriteOutput() (Ch 54)XmlChildPos() (Ch 55, XML)XmlElemNew() (Ch 55, XML)XmlFormat() (Ch 55, XML)XmlNew() (Ch 55, XML)XmlParse() (Ch 55, XML)XmlSearch() (Ch 55, XML)XmlTransform() (Ch 55, XML)Year() (Ch 48, Dates and Times)YesNoFormat() (Ch 48, Strings)

Trang 38

Designing Your Application

sessionManagement = “NO | YES” Enables Session variables.

sessionTimeout = #CreateTimeSpan(0,0,20,0)# Lifespan of Session variables Defaults to the value specified in

ColdFusion Administrator.

setClientCookies = “YES | NO” Sends CFID and CFTOKEN cookies to browser.

setDomainCookies = “NO | YES”> Required if the application runs on a cluster.

Trang 40

General Use Tags and Functions

General

<CFCACHE>

Stores the static HTML generated by a ColdFusion template in a temporary file on the server and retrieves it instead of the requested ColdFusion template during the specified time span Judicious use of CFCACHE on ColdFusion templates that generate latent content can greatly increase the overall performance of ColdFusion applications.

<CFCACHEaction = “CACHE Both Client- and Server-side caching.

| CLIENTCACHE Client-side caching only.

| SERVERCACHE Server-side caching only.

Generates custom HTTP response headers and returns them to the client browser.

Can also be used to change the HTTP status code Cannot be called after a CFFLUSH.

If creating a response header:

<CFHEADER

name = “#headerName#”

value = “#headerValue#”>

47

Ngày đăng: 14/08/2014, 01:21

TỪ KHÓA LIÊN QUAN