Wednesday, April 9, 2008

Java Server Pages integration_12

ColdFusion MX is built on top of the same platform that runs JSP (or Java Server Pages). You

can, therefore, include JSP pages in your application, and you can share variables between

ColdFusion and JSP! We can set a Session variable, for example, in MyCFPage.cfm as follows:

<cfset Session.myvar = 1>

And we can then output it on MyJSPPage.jsp as follows:

<%= session.getAttribute("myvar") %>

This example may illustrate only the general principle behind sharing data between the two

platforms, but imagine the possibilities. For more information about integrating ColdFusion

with Java technologies.

Simplified locking_11

Because ColdFusion MX is now built on Java, you no longer need to worry about data corruption

in the shared memory scopes: Session, Application, and Server. Unfortunately, this fact has been misinterpreted by some to mean

"Hey—I don't need to lock my Session variables anymore!" Nothing can be farther from the

truth.

You still need to lock shared memory scopes to prevent what are known as race conditions,

where one piece of code may interfere with another that is also trying to access the same

data in shared memory. Race conditions are more prevalent than you may think; all in all,

you're most likely to continue to lock shared memory scopes almost as much as you did in

earlier versions of ColdFusion.

The new locking rules do enable you to safely read and write "write-once" variables in shared

memory scopes without locking. So if you have a Session variable that is created only once

during a session, is never destroyed and recreated, is never modified under any conditions

whatsoever, and is never CFSET a second time—even with the same value that it had previously—

you do not need to lock access to it.

Simplified Verity administration_10

Verity is the name of the company who invented the full-text search technology use by

ColdFusion MX, so full-text searching in ColdFusion is commonly referred to as "Verity

searching." A full-text search is what you perform on popular search sites like Google and

Yahoo, where you can search for a word or phrase, the search engine looks inside collections

containing billions of web pages for that word or phrase, and returns a weighted list of results

that most likely best fit what you're looking for.

Expansions to the Verity full-text search system have made managing a site that uses Verity

easier than ever. You can now obtain a list of all the Verity collections on your server (as well

as some extra metadata, such as where they are stored and whether they are K2 Server (a

high performance standalone Verity server) collections) by using the CFCOLLECTION tag, as

follows:

<cfcollection action="LIST" name="GetCollections">

ColdFusion MX offers new Verity-related functions and still more improvements over earlier

versions of ColdFusion.

Sandbox Security_9

Available only in the Enterprise version of ColdFusion MX (although Professional has a similar

feature, named Resource Security), Sandbox Security is a great feature for shared hosts or people

running a department with multiple applications, because it enables a site administrator

to restrict what resources the code on his server can access. The administrator can, for

example, restrict the code in one directory from accessing specific tags and datasources, and

he can restrict code in another directory from accessing a completely different set of tags and

datasources.

Simplified security_7

Does anyone remember Advanced Security? Does anyone want to suffer through that again?

ColdFusion MX makes security easier to manage in two ways: application security by using the

new CFLOGIN tag (and its related tags and functions) and the new J2EE-integrated Sandbox

Security. The following sections briefly describe these two methods of security.

Native XML handling_6

Finally, ColdFusion can handle XML! If you've never heard of it before, XML stands for

eXtensible Markup Language, and it provides a way to structure data and encode it with

additional information using a plain text format that can be used by most modern application

servers and applications. Previously, data interchange with XML was limited to one of the

following two options in ColdFusion:

Use WDDX as an interchange format: This was a good start, but it was limited because

you were locked in to a data-centric flavor of XML. (WDDX is explained in detail in

Chapter 30.)

Use a COM object or third-part custom tag library: Some good libraries were on the

market, but they still are no match for the capability to natively use XML and XML

objects.

Now, by using ColdFusion MX, all you need do to create an XML object is use the new CFXML

tag, as follows:

<cfxml variable="XmlObj">

<my-xml-tag>

<my-child-tag />

</my-xml-tag>

</cfxml>

And that's only the beginning of an impressive array of XML handling features; in fact, the

only feature missing from ColdFusion's XML implementation is the capability to validate

against a DTD or XMLSchema document, which can be easily remedied by using COM. For

more information about validating XML with ColdFusion MX, see Chapter 29.

ColdFusion MX also natively handles XSLT transformations, so you can transform structured

XML documents into virtually any type of content. MX's XPath capabilities enable you to

query an XML object and extract data structures that match search criteria.

After you parse an XML document into an XML object, you can refer to its data elements by

using the same ColdFusion syntax used for handling arrays and structures, so your learning

curve remains relatively small.

Web services_5

A Web service exposes a software component to remote systems in a platform-independent

manner, meaning that any application server platform capable of consuming web services

can make use of the web services created with ColdFusion MX. ColdFusion MX truly rang the

bell with its implementation of Web services: To create a Web service in MX, you simply set

the Access attribute of a ColdFusion component function to Remote. No, really!

You need to pay attention to a few details, of course, but creating a Web service is a natural

extension to ColdFusion's component functionality. Whenever a ColdFusion component is

accessed as a Web service, the remote consumer of the Web service receives the result in the

native format of the consumer's platform, so .NET consumers receive ColdFusion arrays as

.NET arrays, and Java consumers receive them as Java arrays.

Some incompatibilities do exist between certain ColdFusion complex data types and specific

consumer platforms, but these hurdles can be cleared by exchanging complex data as XML

documents that the consumer may then transform as needed.

One piece of advice: Learn Web services, XSLT transformations

, and how to validate XML documents against DTDs by using COM. These

skills may sound foreign to you now, but they're soon to be in very high demand, and we

want you there to provide the necessary solutions.