Writing A Java Cfx; Processing Requests - MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual

Table of Contents

Advertisement

Writing a Java CFX

Writing a Java CFX

To create a Java CFX, you create a class that implements the
This interface contains one method,
Response
To create a Java CFX:
1
2
3
4
If you receive errors during compilation, check the source code to make sure you
entered it correctly. If no errors occur, you just successfully wrote your first Java CFX.
As you can see, implementing the basic
is all a Java class must do to be callable from a CFML page.

Processing requests

Implementing a Java CFX requires interaction with the
objects passed to the
with ColdFusion queries also interface with the
package, located in the classes/cfx.jar archive, contains the
Query
objects that are then used to do the work of the tag.
Create a new source file in your editor.
Enter your code. The following code shows how t o create a very simple Java CFX
named
SimpleJavaCFX
import com.allaire.cfx.* ;
public class HelloColdFusion implements CustomTag
{
public void processRequest( Request request, Response response )
throws Exception
{
String strName = request.getAttribute( "NAME" ) ;
response.write( "Hello, " + strName ) ;
}
}
Save the file as
HelloColdFusion.java
Compile the java source file into a class file using the Java compiler. If you are
using the command-line tools bundled with the JDK, use the following command
line, which you execute from within the
javac -classpath cfx.jar HelloColdFusion.java
Note
The previous command works only if the Java compiler (
path. If it is not in your path, specify the fully qualified path; for example,
c:\jdk12\bin\javac on Windows NT or /usr/java/bin/javac on UNIX.
processRequest
objects.
processRequest
that writes a text string back to the calling page:
in the
classes
CustomTag
method. In addition, CFXs that need to work
CustomTag
, which is passed
subdirectory.
classes
directory:
javac.exe
interface is straightforward. This
Request and Response
object. The com.allaire.cfx
Query
,
Request
393
interface.
and
Request
) is in your
, and
Response

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?

This manual is also suitable for:

Coldfusion 5

Table of Contents