User Guide

Table Of Contents
928 Chapter 37: Integrating J2EE and Java Elements in CFML Applications
Request.myVariable: #Request.myVariable#<br>
Session.myVariable: #Session.myVariable#<br>
Application.myVariable: #Application.myVariable#<br>
</cfoutput>
Reviewing the code
The following table describes the CFML code and its function:
Using Java objects
You use the cfobject tag to create an instance of a Java object. You use other ColdFusion tags,
such as
cfset and cfoutput, or CFScript to invoke properties (attributes), and methods
(operations) on the object.
Method arguments and return values can be any valid Java type; for example, simple arrays and
objects. ColdFusion does the appropriate conversions when strings are passed as arguments, but
not when they are received as return values. For more information on type conversion issues, see
“Java and ColdFusion data type conversions” on page 933.
The examples in the following sections assume that the
name attribute in the cfobject tag
specified the value obj, and that the object has a property called Property, and methods called
Method1, Method2, and Method3.
Note: The cfdump tag displays an object’s public methods and data.
Using basic object techniques
The following sections describe how to invoke Java objects.
Invoking objects
The
cfobject tag makes Java objects available in ColdFusion MX. It can access any Java class
that is available on the JVM classpath or in either of the following locations:
In a Java archive (.jar) file in web_root/WEB-INF/lib
In a class (.class) file in web_root/WEB-INF/classes
Code Description
<cfapplication name="myApp"
sessionmanagement="yes">
Specifies the application name as myApp and enables session
management. In most applications, this tag is in the
Application.cfm page.
<cfoutput>
<h2>Hello #URL.name#!</h2>
Displays the name passed using the jsp:param tag on the JSP
page. The parameter name is not case-sensitive.
Request.myVariable:
#Request.myVariable#<br>
Session.myVariable:
#Session.myVariable#<br>
Application.myVariable:
#Application.myVariable#<br>
</cfoutput>
Displays the Request.myVariable, Session. myVariable, and
Application.myVariable values. Note that all variable names on
CFML pages are case independent.