User Guide

Table Of Contents
Interoperating with JSP pages and servlets 927
<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:
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>
Code Description
<%@page import="java.util.*" %>
Imports the java.util package. This contains methods
required in the JSP page.
<% request.setAttribute("myvariable",
"This");%>
Uses the setAttribute method of the JSP request
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.
<% ((Map)session.getAttribute("myApp"))
.put("myVariable", "is a");%>
Uses the getAttribute method of the JSP session
object to get the myApp object (the Application scope).
Casts this to a Java Map object and uses the
set
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.
<% ((Map)application.getAttribute
("myApp")).put("myVariable",
"test.");%>
Uses the getAttribute method of the JSP application
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.
<jsp:include page="hello.cfm">
<jsp:param name="name"
value="Robert" />
</jsp:include>
Sets the name parameter to Robert and calls the
ColdFusion page hello.cfm.