User Guide

Table Of Contents
Writing a Java CFX tag 261
Configuring the classpath
To configure your development environment to build Java CFX tags, you must ensure that the
supporting classes are visible to your Java compiler. These classes are located in the cfx.jar archive,
located in one of the following directories:
Server configuration cf_root/wwwroot/WEB-INF/lib
J2EE configuration cf_webapp_root/WEB-INF/lib
Consult your Java development tool documentation to determine how to configure the compiler
classpath for your particular environment.
The cfx.jar archive contains the classes in the
com.allaire.cfx package, which are required for
developing and deploying Java CFX tags.
When you create new Java CFX tags, you should compile them into the WEB-INF/classes
directory. Doing this simplifies your development, debugging, and testing processes.
After you finish with development and testing, you can deploy your Java CFX tag anywhere on
the classpath visible to ColdFusion. For more details on customizing the classpath, see
“Customizing and configuring Java.
Customizing and configuring Java
Use the JVM and Java Settings page on the ColdFusion MX Administrator Server tab to
customize your Java development environment, such as by customizing the classpath and Java
system properties, or specifying an alternate JVM. For more information, see the ColdFusion MX
Administrator online Help.
Writing a Java CFX tag
To create a Java CFX tag, create a class that implements the Custom tag interface. This
interface contains one method,
processRequest, which is passed Request and Response objects
that are then used to do the work of the tag.
The example in the following procedure creates a very simple Java CFX tag named
cfx_MyHelloColdFusion that writes a text string back to the calling page.
To create a Java CFX tag:
1.
Create a new source file in your editor with the following code:
import com.allaire.cfx.* ;
public class MyHelloColdFusion implements CustomTag {
public void processRequest( Request request, Response response )
throws Exception {
String strName = request.getAttribute( "NAME" ) ;
response.write( "Hello, " + strName ) ;
}
}
2.
Save the file as MyHelloColdFusion.java in the WEB_INF/classes directory.