Whatever message this page gives is out now! Go check it out!
GetPageContext() .include (" hello.jsp "); |
getPageContext () .forward (URLEncodedFormat("/ responsegen / responsegen .jsp ?#urlParams#")); |
testServlet . Use the function GetPageContext() .forward (' testServlet '). This function gets the current ColdFusion PageContext object that provides access to page attributes and configuration, request, and response objects. The cfm page is as follows:C:\<ColdFusion Installation Directory>\wwwroot\WEB-INF\classes\ for stand-alone installation of ColdFusion.C:\<App server>\servers\<coldfusion instance name>\cfusion-ear\cfusion-war\WEB-INF\classes\ for ColdFusion in multiple servers.web.xml. This file is present in the following locations:C:\<ColdFusion Installation Directory>\wwwroot\WEB-INF\ for stand-alone installation of ColdFusion.C:\<App server>\servers\<coldfusion instance name>\cfusion-ear\cfusion-war\WEB-INF\ for ColdFusion in multiple servers.((Map)application. getAttribute ("CFApplicationName"))) .get (" appVarName ") |
((Map)(session. getAttribute ("CFApplicationName"))) .get (" sessionVarName ") |
Scope | Can share data using |
Request | forward, include*Note:* Shared Request scope variable names in the JSP page or servlet must be all-lowercase. |
Session | href, cfhttp, forward, include |
Application | href, cfhttp, forward, include |
getPageContext () .forward (URLEncodedFormat("/ responsegen / responsegen .jsp ")); |
application.getAttribute("applicationVariableName") |
session.getAttribute("sessionVariableName") |
<cfscript> Request.myVariable = "This"; Session.myVariable = "is a"; Application.myVariable = "test."; GetPageContext().include("hello.jsp?name=Bobby"); </cfscript> |
Code | 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 function to get the current servlet page context for the ColdFusion page. Uses the include method of the page context object to call the hello. jsp page. Passes the name parameter in the URL. |
<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")%> |
Code | Description | |
| Imports the java.util package. This package 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 to get form fields. | |
| Uses the getAttribute method of the JSP request object to displays the value of the Request scope variable myVariable .The JSP page must use all lowercase characters to reference 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 or all uppercase on the JSP page, the variable is not set from the ColdFusion page. | |
| Uses the getAttribute method of the JSP session object to get the myApp object (the Application scope). Casts this object 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 method of the JSP myApp 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. |
<% 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> |
Code | Description | |
| Imports the java.util package. This package contains methods required in the JSP page. | |
| 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 does not share it with the ColdFusion page. | |
| Uses the getAttribute method of the JSP session object to get the myApp object (the Application scope). Casts this object 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. | |
| 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. | |
| Sets the name parameter to Robert and calls the ColdFusion page hello.cfm . |
<cfoutput> <h2>Hello #URL.name#!</h2> Request.myVariable: #Request.myVariable#<br> Session.myVariable: #Session.myVariable#<br> Application.myVariable: #Application.myVariable#<br> </cfoutput> |
Code | 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 :param tag on the JSP page. The parameter name is not case sensitive. | |
| Displays the Request. myVariable , Session. myVariable , and Application.myVariable values. All variable names on CFML pages are case independent. |