CFDJ Vol. 3 , Issue 3- pg.34
Five Ways To Call Client- And Server-Side Java From CF, by Andrew Cripps


Listing 1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
#cfhttp.filecontent#


Listing 2

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!---   Andrew Cripps, Sept. 2000               --->
<!---   Create a weblogic environment object that allows us to
       look up the bean ìEmployeeHomeî
--->
<CFOBJECT ACTION="Create"
        TYPE="Java"
        CLASS="weblogic/jndi/Environment"
        NAME="wlEnv">
<!--- Get the context --->
<CFSET ctx=wlEnv.getInitialContext()>
<!--- Use the lookup method of the context --->
<CFSET ejbHome=ctx.lookup("EmployeeHome")>


<!--- accepts ID as input and calls EJB component to do lookup --->
<cfparam name="form.id" default="1">


<!--- Call the findByEmployeeID method --->
<cfset temp =  ejbHome.findByEmployeeID("#form.id#")>
<!--- Call the getEmployeeName method--->
<cfset value = temp.getEmployeeName()>
<!--- Output the results--->
Calls Employee EJB
Value from EmployeeBean is #value#


Listing 3

/* java class to print Hello World */
import com.allaire.cfx.* ;


public class HelloWorld implements CustomTag
{
   public void processRequest( Request request, Response response )
      throws Exception
   {
      String strName = request.getAttribute( "NAME" ) ;
      response.write( "Hello, " + strName ) ;
   }
}



Listing 4

<html>
<head>
<title>Call CFX HelloWorld</title>
</head>


<body>
<h1>Calls CFX_HelloWorld</h1>
<CFX_HelloWorld NAME=îAndrewî>
</body>
</html>