Code
<% ((Map)session.getAttribute("myApp"))
.put("myVariable", "is a");%>
<% ((Map)application.getAttribute
("myApp")).put("myVariable",
"test.");%>
<jsp:include page="hello.cfm">
<jsp:param name="name"
value="Robert" />
</jsp:include>
The following hello.cfm page is called by the JSP page. It displays the Name parameter in a
heading and the three variables in the remainder of the body.
<cfapplication name="myApp" sessionmanagement="yes">
<cfoutput>
<h2>Hello #URL.name#!</h2>
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:
Code
<cfapplication name="myApp"
sessionmanagement="yes">
<cfoutput>
<h2>Hello #URL.name#!</h2>
Request.myVariable:
#Request.myVariable#<br>
Session.myVariable:
#Session.myVariable#<br>
Application.myVariable:
#Application.myVariable#<br>
</cfoutput>
Description
Uses the
getAttribute
object to get the myApp object (the Application scope).
Casts this to a Java Map object and uses the
method to set the myVariable value.
CFML pages and JSP pages share Session variables
independent of the variable name case. The variable on
the JSP page can have any case mixture and still share
the value with the ColdFusion page. For example,
instead of myVariable, you could use MYVARIABLE or
myvariable on this line.
Uses the
getAttribute
object to get myApp object (the Application scope) and
casts it to a Map object. It then sets the value of
myVariable in the myApp application scope object.
CFML pages and JSP pages share Application
variables independent of the variable name case. The
variable on the JSP page can have any case mixture
and still share the value with the ColdFusion page. For
example, instead of myVariable, you could use
MYVARIABLE or myvariable on this line.
Sets the name parameter to Robert and calls the
ColdFusion page hello.cfm.
Description
Specifies the application name as myApp and enables
session management. In most applications, this tag is in the
Application.cfm page.
Displays the name passed using the
JSP page. The parameter name is not case-sensitive.
Displays the Request.myVariable, Session. myVariable, and
Application.myVariable values. Note that all variable names
on CFML pages are case independent.
Interoperating with JSP pages and servlets
method of the JSP session
set
method of the JSP application
tag on the
jsp:param
745
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers