Using java objects in coldfusion
i have java object, needs used in cfm page. java object references classes external jar file. i've copied java object class, , external jar files in 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 method.
int statuscode = client.executemethod(method);
if (statuscode != httpstatus.sc_ok) {
connected=false;
}
connected=true;
} catch (exception e) {
connected=false;
} {
// release connection.
method.releaseconnection();
}
return(connected);
}
}
-----------------------------------------------------------------------
i'm accessing object in following way within cfm:
----------------------
<cfobject action="create" type="java" class="testobj" name="tobj">
<cfset connctd=tobj.connect(" http://some url...")>
----------------------
i error '500 null' when load cfm. when comment out code httpclient , related objects in testobj , reload page, don't see error. makes me think httpclient not accessible java object in coldfusion environment though i've copied related jar files httpclient , other objects in web-inf/lib directory.
so question is: can java object, being called coldfusion page, reference other java objects available in jar files in coldfusion environment?
any on appreciated.
thanks
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 method.
int statuscode = client.executemethod(method);
if (statuscode != httpstatus.sc_ok) {
connected=false;
}
connected=true;
} catch (exception e) {
connected=false;
} {
// release connection.
method.releaseconnection();
}
return(connected);
}
}
-----------------------------------------------------------------------
i'm accessing object in following way within cfm:
----------------------
<cfobject action="create" type="java" class="testobj" name="tobj">
<cfset connctd=tobj.connect(" http://some url...")>
----------------------
i error '500 null' when load cfm. when comment out code httpclient , related objects in testobj , reload page, don't see error. makes me think httpclient not accessible java object in coldfusion environment though i've copied related jar files httpclient , other objects in web-inf/lib directory.
so question is: can java object, being called coldfusion page, reference other java objects available in jar files in coldfusion environment?
any on appreciated.
thanks
ashishpomal wrote:
> question is: can java object, being called coldfusion page,
> reference other java objects available in jar files in coldfusion environment?
i not speaking authority here, i've done bit of java ,
coldfusion, believe so. first thought since moved
associated files paths wrong?
> import org.apache.commons.httpclient.*;
> import org.apache.commons.httpclient.methods.*;
> import org.apache.commons.httpclient.params.httpmethodparams;
are these not looking these jars in
/org/apache/commons/httpclient/ directory? if have moved them
the web-inf/lib directory not different path , not
need reflected in above import statements?
> question is: can java object, being called coldfusion page,
> reference other java objects available in jar files in coldfusion environment?
i not speaking authority here, i've done bit of java ,
coldfusion, believe so. first thought since moved
associated files paths wrong?
> import org.apache.commons.httpclient.*;
> import org.apache.commons.httpclient.methods.*;
> import org.apache.commons.httpclient.params.httpmethodparams;
are these not looking these jars in
/org/apache/commons/httpclient/ directory? if have moved them
the web-inf/lib directory not different path , not
need reflected in above import statements?
More discussions in Advanced Techniques
adobe
Comments
Post a Comment