A child of cfservlet
. It passes data to the servlet. Each cfservletparam
tag within the cfservlet
block passes a separate piece of data to the servlet.
Java servlet and Java object tags
<cfservlet ...> <cfservletparam name = "servlet parameter name" value = "servlet parameter value"> ... <cfservletparam name = "servlet attribute name" variable = "coldfusion variable name" type = "INT" or "DOUBLE" or "BOOL" or "DATE" or "STRING"> ... </cfservlet>
The cfservletparam
tag can be used in two ways to pass information to a servlet: by value or by reference. Depending on the method used, this information appears in the servlet either as a parameter (by value) or attribute (by reference).
The first method passes name-value pairs by value. This method uses the attributes name
and value
to pass a simple name-value string pair to the servlet. The name
attribute represents the name of the servlet parameter from which the string specified in the value
attribute can be retrieved. Although the servlet can use these parameters as input, it cannot change their values in the ColdFusion template.
The second method passes a ColdFusion variable to the servlet by reference. This method uses the attribute variable
to pass the specified ColdFusion variable by reference to the servlet. Within the servlet, the variable data is made available as servlet attributes in the form of Java objects. On the Java side, the data can be manipulated, or changed, changing the value of the associated ColdFusion variable.
When used in this mode, the name
attribute represents the name of the servlet attribute that is created to hold the value of the ColdFusion variable. The variable
attribute represents the name, not the #value#, of a ColdFusion variable. This ability to directly share ColdFusion variables with a servlet is a powerful extension to the servlet API because it allows even complex ColdFusion objects, such as structures, and result sets to be directly accessed from Java. The following table shows the mapping between ColdFusion data types (specified with the type
attribute) and the corresponding Java objects.
Note In order for the Name/Variable functionality to work, you must have JRun 3.0 or later. Download the latest version of JRun at the following URL: |
To return a modified attribute to ColdFusion, thereby changing the value of the ColdFusion variable, you must call the servlet API setAttribute method from the servlet to reset the value of the attribute.
<cfservlet
code = "MyServletName" JRunProxy = "236.3.3.4:8083" timeout = "300" writeOutput = "Yes" debug = "Yes"> <cfservletparam name = "Param1" value = "Value1"> <cfservletparam name = "Param2" value = "Value2"> <cfservletparam name = "Attribute1" variable = "CFVar1" type = "BOOL"> <cfservletparam name = "Attribute2" variable = "CFVar2"> </cfservlet>