There are four basic ways to use Java with ColdFusion:
- CFX tags
- JSP tags
createObject()to accesses custom classes in your classpath
- Direct embedding (usually using CFScript)
CFX tags have a very straightforward interface. You simply implement a function called processRequest contained in the interface
com.allaire.cfx.CustomTag, and work with the Request and Response objects that get passed in. CFX tags are the easiest way to implement ColdFusion tags in Java. The JSP custom tag interface is much more complex and flexible, allowing you to respond to very specific tag parsing events, nest tags, and work with body content. Using the
CFOBJECT tag or
createObject function is as easy or difficult or as the APIs you are accessing, while the simplest way to work with Java in ColdFusion is probably to embed it directly, typically using CFScript.
How often do you find yourself using Java in your ColdFusion applications? What do you typically use it for, or what have you used it for in the past? Finally, which of the techniques above do you typically use, and why?