CFSERVLET

Executes a Java servlet on a JRun engine. This tag is used in conjunction with the CFSERVLETPARAM tag, which passes data to the servlet.

Syntax

<CFSERVLET 
    CODE="class name of servlet"
    JRUNPROXY="proxy server"
    TIMEOUT="timeout in seconds"
    WRITEOUTPUT="Yes/No"
    DEBUG="Yes/No">
    <CFSERVLETPARAM 
    NAME="parameter name" 
    VALUE="value" 
    > 
    ...
</CFSERVLET>

CODE

Required. The class name of the Java servlet to execute.

JRUNPROXY

Optional. Specifies a remote machine where the JRun engine is executing. By default, the JRun engine is assumed to be on the host running ColdFusion. To indicate the name of a remote host, specify the IP address of the remote host followed by a colon and the port number at which JRun is listening. By default, JRun listens at port 8081.

TIMEOUT

Optional. Specifies how many seconds JRun should wait for the servlet to complete before timing out.

WRITEOUTPUT

Optional. Boolean specifying if the text output of the tag should appear as inline text on the generated page or if it should be returned inside a ColdFusion variable for further processing . The default value, YES, means output is returned as text to appear inline on the generated page. Setting it to NO means no visible text is returned but, instead, the text is returned as the value of the CFSERVLET.OUTPUT variable. See the CFSERVLET Variables table under Usage for more information.

DEBUG

Optional. Boolean specifying whether additional information about the JRun connection status and activity is to be written to the JRun error log. The error log is in JRunHome/jsm-default/logs/stderr.log. Reading this log is helpful for debugging server-side problems. The default is No.

Usage

The syntax of the CFSERVLET tag is designed to be consistent with the HTML markup <SERVLET> and <PARAM> used by some web servers to invoke Java servlets from .shtml pages in what is known as SSI, Server-Side Includes.

CFSERVLET Variables
Variable Name Description
CFSERVLET.Output Inline text output of the servlet is directed to this structure if the WRITEOUTPUT attribute is set to No.
CFSERVLET.servletResponseHeaderName The CFSERVLET return structure also contains the values of any response headers returned by the servlet. To access a response header, specify its name in servletResponseHeaderName.

Note The servlet must exist somewhere in the class path of the JRun engine executing the servlet. The JRun "servlet" subdirectory is a good location since it is already in JRun's class path and because classes in this directory are automatically reloaded by JRun if they change.

Example

<CFSERVLET  CODE="MyServletName" 
    JRUNPROXY="236.3.3.4:8083" 
    TIMEOUT="300"
    WRITEOUTPUT="YES">
    <CFSERVLETPARAM  NAME="Param1"  VALUE="Value1"> 
    <CFSERVLETPARAM  NAME="Param2"  VALUE="Value2">
    <CFSERVLETPARAM  NAME="Attribute1"  VARIABLE="CFVar1">
    <CFSERVLETPARAM  NAME="Attribute2"  VARIABLE="CFVar2">
</CFSERVLET>