I have a java object, that needs to be used in a cfm page.
The java object itself references classes from an external jar
file. I've copied the java object class, and the external jar files
in the web-inf/lib directory of coldfusion.
My java object is:
--------------------------------------------------------------------------------
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
public class TestObj{
public TestObj() {
// TODO Auto-generated constructor stub
}
public boolean Connect(String url)
{
boolean connected=true;
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(0, false));
try {
// Execute the method.
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
connected=false;
}
connected=true;
} catch (Exception e) {
connected=false;
} finally {
// Release the connection.
method.releaseConnection();
}
return(connected);
}
}
-----------------------------------------------------------------------
I'm accessing the object in the following way within the cfm:
----------------------
<cfobject action="create" type="Java" class="TestObj"
name="tobj">
<cfset connctd=tobj.Connect("
http://some url...")>
----------------------
I get an error '500 null' when I load this cfm. When I
comment out the code for httpclient and related objects in TestObj
and reload the page, I don't see an error. This makes me think that
httpclient is not accessible to the java object in the coldfusion
environment even though I've copied the related jar files for
httpclient and the other objects in the web-inf/lib directory.
So my question is: Can a java object, being called from a
coldfusion page, reference other java objects available in jar
files in a coldfusion environment?
Any help on this is greatly appreciated.
Thanks