cfdocs

cfjava

Provides support for writing Java code within ColdFusion.

Syntax

<cfjava handle="classInstance">

Script Syntax ACF11+, Lucee, Railo 4.2+

cfjava(handle="classInstance");

Attribute Reference

Name Type Required Default Description
handle variableName Yes   The variable that holds the value of class instance of the Java code.

Create Name instance (Tag syntax)

<cfjava handle="nameInstance">
    public class Name {
        private String firstName;
        private String lastName;

        public Name(String firstName, String lastName) {
            this.firstName = firstName;
            this.lastName = lastName;
        }

        public String getFullName() {
            return firstName + " " + lastName;
        }
    }
</cfjava>
<cfset nameInstance.init("John", "Doe")>
<cfset fullName = nameInstance.getFullName()>
<cfoutput>#fullName#</cfoutput>

Expected Result: John Doe