ColdFusion is built on a J2EE-compliant Java technology platform. This lets ColdFusion applications take advantage of, and integrate with, J2EE elements. ColdFusion pages can do any of the following:
ColdFusion pages, like HTML pages, can incorporate client-side JavaScript and Java applets. To use JavaScript, you write the JavaScript code just as you do on any HTML page. ColdFusion ignores the JavaScript and sends it to the client.
The cfapplet
tag simplifies using Java client-side applets.
cfapplet
tag to call the applet. The appletSource
attribute must be the Applet name assigned in ColdFusion Administrator.For example, ColdFusion includes a Copytext sample applet that copies text from one text box to another. The ColdFusion Setup automatically registers the applet in the Administrator. To use this applet, incorporate it on your page. For example:
<cfform action = "copytext.cfm">
<cfapplet appletsource = "copytext" name = "copytext"> </cfform>
ColdFusion supports JSP tags and pages in the following ways:
cfimport
tag imports JSP tag libraries and lets you use its tags.ColdFusion pages are not JSP pages, however, and you cannot use most JSP syntax on ColdFusion pages. In particular you cannot use the following features on ColdFusion pages:
include
and import
tags to include pages and import tag libraries.
Some Java servlets are not exposed as JSP pages; instead they are Java programs. You can incorporate JSP servlets in your ColdFusion application. For example, your enterprise might have an existing servlet that performs some business logic. To use a servlet, the ColdFusion page specifies the servlet by using the ColdFusion GetPageContext
function.
When you access the servlet with the GetPageContext
function, the ColdFusion page shares the Application, Session, and Request scopes with the servlet, so you can use these scopes for shared data.
ColdFusion pages can also access servlets by using the cfhttp
tag, use the servlet URL in a form
tag, or access an SHTML page that uses a servlet
tag.
Note: The cfservlet
tag, which provides access to servlets on JRun servers, is deprecated for ColdFusion MX.
Java objects include the following:
ColdFusion pages use the cfobject
tag to access Java objects.
ColdFusion searches for the objects in the following order:
ColdFusion reloads classes from these directories, as described in the next section, "About class loading" .
ColdFusion dynamically loads classes that are either .class files in the web_root/WEB-INF/classes directory or in JAR files in the web_root/WEB-INF/lib directory. ColdFusion checks the time stamp on the file when it creates an object that is defined in either directory, even when the class is already in memory. If the file that contains the class is newer than the class in memory, ColdFusion loads the class from that directory.
To use this feature, make sure that the Java implementation classes that you modify are not in the general JVM classpath.
To disable automatic class loading of your classes, put the classes in the JVM classpath. Classes located on the JVM classpath are loaded once per server lifetime. To reload these classes, stop and restart ColdFusion Server.
Note: Because you put tag libraries in the web_root/WEB-INF/lib directory, ColdFusion automatically reloads these libraries if necessary when you import the library.
Because ColdFusion pages are J2EE servlet pages, all ColdFusion pages have an underlying Java PageContext object. CFML includes the GetPageContext
function that you can then use in your ColdFusion page.
The PageContext object exposes a number of fields and methods that can be useful in J2EE integration. In particular, it includes the include
and forward
methods that provide the equivalent of the corresponding standard JSP tags.
This chapter describes how to use the include
and forward
PageContext methods for calling JSP pages and servlets. It does not discuss the PageContext object in general. For more information on the object, see Java documentation. You can find the Javadoc description of this class at http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/jsp/PageContext.html.