MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 744

Developing coldfusion mx applications
Table of Contents

Advertisement

Code
<br>session.myVariable:
<%=
((Map)(session.getAttribute("myApp
"))).
get("myVariable")%>
<br>Application.myVariable: <%=
((Map)(application.getAttribute("m
yApp")))
.get("myVariable")%>
Calling a ColdFusion page from a JSP page
The following JSP page sets Request, Session, and application variables and calls a ColdFusion
page, passing it a name parameter:
<%@page import="java.util.*" %>
<% request.setAttribute("myvariable", "This");%>
<% ((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>
Reviewing the code
The following table describes the JSP code and its function:
Code
<%@page import="java.util.*" %>
<% request.setAttribute("myvariable",
"This");%>
744
Chapter 33: Integrating J2EE and Java Elements in CFML Applications
Description
Uses the
getAttribute
object to get the myApp object (the Application scope).
Casts this to a Java Map object and uses the get method
to obtain the myVariable value for display.
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 receive
the value from the ColdFusion page. For example,
instead of myVariable, you could use MYVARIABLE or
myvariable on this line.
Uses the
getAttribute
application object to obtain the value of myVariable in
the Application scope.
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 receive
the value from the ColdFusion page. For example,
instead of myVariable, you could use MYVARIABLE or
myvariable on this line.
Description
Imports the java.util package. This contains methods
required in the JSP page.
Uses the
setAttribute
object to set the value of the Request scope variable
myVariable.
The JSP page must use all lowercase characters to
refer to all request scope variables that it shares with
CFML pages. You can use any case on the CFML
page, but if you use mixed case to all uppercase on the
JSP page, the JSP page will not share it with the
ColdFusion page.
method of the JSP session
method of the JSP myApp
method of the JSP request

Advertisement

Table of Contents
loading
Need help?

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

This manual is also suitable for:

Coldfusion mx

Table of Contents