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.
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 ) ; } }
javac -classpath cf_root\WEB-INF\lib\cfx.jar MyHelloColdFusion.java
Note: The previous command works only if the Java compiler (javac.exe
) is in your path. If it is not in your path, specify the fully qualified path; for example, c:\jdk1.3.1_01\bin\javac on Windows or /usr/java/bin/javac on UNIX.
If you receive errors during compilation, check the source code to make sure you entered it correctly. If no errors occur, you successfully wrote your first Java CFX tag. For information on using your new tag in a ColdFusion page, see Calling the CFX tag from a ColdFusion page.
This section describes the following topics: