Listing 1
1.// import the Java CFAPI
2.import com.allaire.cfx.* ;
3.
4.public class HelloWorld implements CustomTag
5.{
6.// custom tag entry point
7.public void processRequest(Request request, Response
response)
8.throws Exception
9.{
10.String strName = null;
11.String strGreeting = null;
12.
13.// retrieve/default the incoming argument
14.strName = request.getAttribute("NAME", "World");
15.
16.strGreeting = "Hello, " + strName;
17.
18.// write it back to the display stream
19.response.write(strGreeting);
20. }
21.}
Listing 2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Hello, World CFX</title>
</head>
<body>
<cfx_hello>
</body>
</html>
Listing 3
// import the Java CFAPI
import com.allaire.cfx.* ;
public class HelloQuery implements CustomTag
{
// custom tag entry point
public void
processRequest(Request request, Response response)
throws Exception
{
int nRowCount, nRowIndex, nColumnIndex;
Query qry = null;
if(request.attributeExists("QUERY"))
{
qry = request.getQuery();
}
else
{
throw new Exception("<h2>Error!</h2>No Query
attribute passed.");
}
nRowCount = qry.getRowCount();
nColumnIndex = qry.getColumnIndex("NAME");
for(nRowIndex = 1; nRowIndex <= nRowCount; nRowIndex++)
{
response.write("Hello, " +
qry.getData(nRowIndex, nColumnIndex) + "
");
}
}
}
Listing 4
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Hello, Query CFX</title>
</head>
<body>
<cfquery name="names" datasource="ccoj">
select * from Person
</cfquery>
<cfx_helloquery query="names">
</body>
</html>