Tuesday, October 4, 2011

CFHTTP issue with Connection Failure: Status code unavailable


I was trying to connect to client's remote URL using CFHTTP and I was getting an error saying "Connection Failure: Status code unavailable". So to fix that I used below code and this solved by problem:

<cfobject action="Create" name="objSrvHTTP" class="MSXML2.ServerXMLHTTP">
<cfset temp = objSrvHTTP.open("GET","http://google.com")>
<cfset temp = objSrvHTTP.send("")>
<cfset myResult = objSrvHTTP.responsetext>

Show custom page for run-time exceptions occurred in servlet


In Coldfusion if you see errors in servlet with a stack trace like below:



then in order to get custom error page you need to add this code


<error-page>
<error-code>500</error-code>
<location>/500.cfm</location>
</error-page>


in default-web.xml. You can find this xml in this location C:\JRun4\servers\cfusion\SERVER-INF\.

Ref: http://livedocs.adobe.com/jrun/4/Programmers_Guide/techniques_servlet12.htm

I created the above error by capturing the form post using Live HTTP Headers add on of Firefox and changing the content length and replayed the request. When I do this then cferror was not capturing that error. So had to do this way in order to show custom error.