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

Developing coldfusion mx applications
Table of Contents

Advertisement

Reviewing the code
The following table describes the CFML code and its function:
Code
<cfapplication name="myApp"
sessionmanagement="yes">
<cfscript>
Request.myVariable = "This";
Session.myVariable = "is a";
Application.myVariable =
"test.";
GetPageContext().include
("hello.jsp?name=Bobby");
</cfscript>
The hello.jsp page is called by the ColdFusion page. It displays the
and the three variables in the remainder of the body.
<%@page import="java.util.*" %>
<h2>Hello <%= request.getParameter("name")%>!</h2>
<br>Request.myVariable: <%= request.getAttribute("myVariable")%>
<br>session.myVariable: <%=
((Map)(session.getAttribute("myApp"))).get("myVariable")%>
<br>Application.myVariable: <%=
((Map)(application.getAttribute("myApp"))).get("myVariable")%>
Reviewing the code
The following table describes the JSP code and its function (line breaks added for clarity):
Code
<%@page import="java.util.*" %>
<h2>Hello <%= request.getParameter
("name")%>!</h2>
<br>request.myVariable: <%= request.
getAttribute("myvariable")%>
Description
Specifies the application name as myApp and enables
session management. In most applications, this tag is in the
Application.cfm page.
Sets ColdFusion Request, Session, and Application, scope
variables. Uses the same name, myVariable, for each
variable.
Uses the
GetPageContext
page context for the ColdFusion page. Uses the
method of the page context object to call the hello.jsp page.
Passes the name parameter in the URL.
Description
Imports the java.util package. This contains methods
required in the JSP page.
Displays the name passed as a URL parameter from the
ColdFusion page. The parameter name is case-sensitive,
Note: The getParameter request method cannot get all
ColdFusion page request parameter values on some
application servers. For Example, on IBM WebSphere,
you cannot use
getParameter
Uses the
getAttribute
object to displays 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 variable will not get its value ColdFusion page.
Interoperating with JSP pages and servlets
function to get the current servlet
include
parameter in a header
name
to get form fields.
method of the JSP request
743

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents