<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Elliott&#039;s Development Blog &#187; Adobe</title>
	<atom:link href="http://www.elliottsprehn.com/blog/category/adobe/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elliottsprehn.com/blog</link>
	<description>Exploring Life Through Math, Algorithms and Code</description>
	<lastBuildDate>Mon, 30 Aug 2010 17:25:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Adobe CFBuilder Bug Database Mirror</title>
		<link>http://www.elliottsprehn.com/blog/2010/08/21/adobe-cfbuilder-bug-database-mirror/</link>
		<comments>http://www.elliottsprehn.com/blog/2010/08/21/adobe-cfbuilder-bug-database-mirror/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 10:23:24 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/?p=132</guid>
		<description><![CDATA[A few months ago I released a <a href="http://www.elliottsprehn.com/cfbugs/">mirror</a> of the bug tracker for Adobe ColdFusion written in HTML. It occurred to me shortly after that it would also be useful to have a tracker for CFBuilder bugs.

So I'm happy to announce the <a href="http://www.elliottsprehn.com/cfbuilderbugs/">Unofficial Adobe CFBuilder Bug Database Mirror</a>!]]></description>
			<content:encoded><![CDATA[<p>A few months ago I released a <a href="http://www.elliottsprehn.com/cfbugs/">mirror</a> of the bug tracker for Adobe ColdFusion written in HTML. It occurred to me shortly after that it would also be useful to have a tracker for CFBuilder bugs.</p>
<p>So I&#8217;m happy to announce the <a href="http://www.elliottsprehn.com/cfbuilderbugs/">Unofficial Adobe CFBuilder Bug Database Mirror</a>!</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2010/08/21/adobe-cfbuilder-bug-database-mirror/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CF9 import EXTREMELY SLOW without Component Cache</title>
		<link>http://www.elliottsprehn.com/blog/2010/08/19/cf9-import-extremely-slow-without-component-cache/</link>
		<comments>http://www.elliottsprehn.com/blog/2010/08/19/cf9-import-extremely-slow-without-component-cache/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 06:20:28 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/?p=124</guid>
		<description><![CDATA[ColdFusion 9 has two new features for components. The import statement allows you to use shorter names for components when creating them. The &#8220;Component Cache&#8221; caches the path to components (pretty much Trusted Cache for .cfc files only) to improve performance. Unfortunately there&#8217;s a huge performance problem using the import statement without the Component Cache [...]]]></description>
			<content:encoded><![CDATA[<p>ColdFusion 9 has two new features for components. The import statement allows you to use shorter names for components when creating them. The &#8220;Component Cache&#8221; caches the path to components (pretty much Trusted Cache for .cfc files only) to improve performance. Unfortunately there&#8217;s a huge performance problem using the import statement without the Component Cache turned on. Worse, even with &#8220;Cache in Request&#8221; turned on the performance hit is still the same for every creation.</p>
<p>This performance hit is not some small amount. Creating an empty component that&#8217;s imported will cost anywhere from 8-16ms without the cache. That makes CF7 createObject() performance look fast!</p>
<p>Definitely go <a href="http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=83864">bug Adobe about this</a> because this kind of performance hit makes import useless. Until it&#8217;s fixed leaving component cache off will quickly cripple any new CF9 app and makes development a lot slower too.</p>
<p>Here&#8217;s the bug ticket: <a href="http://www.elliottsprehn.com/cfbugs/bugs/83864">Bug 83864</a></p>
<p>Note:</p>
<p>The reason you might disable Component Cache is because the feature is quite buggy and has a tendency to resolve components to the wrong locations between applications that use application specific mappings. Meaning that most shared hosts will probably need to leave this off. That means that object creation performance is going to be terrible on shared hosts if you use import and don&#8217;t qualify your components, and qualifying them and still using import rather defeats the purpose.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2010/08/19/cf9-import-extremely-slow-without-component-cache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CFUnited 2010 Presentations</title>
		<link>http://www.elliottsprehn.com/blog/2010/08/05/cfunited-2010-presentations/</link>
		<comments>http://www.elliottsprehn.com/blog/2010/08/05/cfunited-2010-presentations/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 04:10:41 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/?p=118</guid>
		<description><![CDATA[I&#8217;ve updated my presentation archive to include my two presentations from CFUnited 2010. If anyone has any questions or suggestions feel free to contact me either by email or posting on here. It was so great to meet everyone new, and see everyone old. Hope to see you at the next conference, whatever that may [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated my presentation archive to include my two presentations from <a href="http://cfunited.com/2010">CFUnited 2010</a>. If anyone has any questions or suggestions feel free to contact me either by email or posting on here. </p>
<p>It was so great to meet everyone new, and see everyone old. Hope to see you at the next conference, whatever that may be!</p>
<ul>
<li class="page_item"><a href="/blog/presentations/designing-scalable-and-creative-algorithms/">Designing Scalable and Creative Algorithms</a></li>
<li class="page_item"><a href="/blog/presentations/i-bet-you-didnt-know-you-could-do-that-with-coldfusion/">I bet you didn&#8217;t know you could do that with ColdFusion</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2010/08/05/cfunited-2010-presentations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adobe ColdFusion Bug Database Mirror</title>
		<link>http://www.elliottsprehn.com/blog/2010/04/11/adobe-coldfusion-bug-database-mirror/</link>
		<comments>http://www.elliottsprehn.com/blog/2010/04/11/adobe-coldfusion-bug-database-mirror/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 07:49:30 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/?p=103</guid>
		<description><![CDATA[This past year Adobe finally released a <a href="http://cfbugs.adobe.com/">bug tracker</a> for ColdFusion. This was a really great move to making CF more developer friendly.

[...]

So I officially announce the <a href="http://www.elliottsprehn.com/cfbugs/">Unofficial Adobe ColdFusion Bug Database Mirror</a>.]]></description>
			<content:encoded><![CDATA[<p>This past year Adobe finally released a <a href="http://cfbugs.adobe.com/">bug tracker</a> for ColdFusion. This was a really great move to making CF more developer friendly.</p>
<p>Unfortunately they also created it in Flex so it&#8217;s a super huge pain to use. For instance lots of the text isn&#8217;t selectable like comments and votes. Undo (Apple+Z) doesn&#8217;t work in any of the text boxes like the search box and even worse the drop down for Bug Areas has (no exaggeration) over 100 items in it with no scrollbar and no keyboard support!</p>
<p>We pushed Adobe on the prerelease to create an HTML UI that wasn&#8217;t so lame, but that never happened. :(</p>
<p>Well, rather than just complain about this I went and created my own.</p>
<p>So I officially announce the <a href="http://www.elliottsprehn.com/cfbugs/">Unofficial Adobe ColdFusion Bug Database Mirror</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2010/04/11/adobe-coldfusion-bug-database-mirror/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using Prototypal Inheritance in ColdFusion</title>
		<link>http://www.elliottsprehn.com/blog/2010/03/24/using-prototypal-inheritance-in-coldfusion/</link>
		<comments>http://www.elliottsprehn.com/blog/2010/03/24/using-prototypal-inheritance-in-coldfusion/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 04:57:21 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/?p=94</guid>
		<description><![CDATA[Ben Nadel was recently looking at Prototypal Inheritance in ColdFusion, which is incidentally one of the topics I talk about in my I bet you didn&#8217;t know you could do that with ColdFusion presentation, which I gave at BFusion 2008 and will be doing an updated version of at CFUnited 2010. &#60;/shameless-plug&#62; The code samples [...]]]></description>
			<content:encoded><![CDATA[<p>Ben Nadel was recently looking at <a href="http://www.bennadel.com/blog/1881-Faking-Prototypal-Inheritance-In-ColdFusion-Components.htm">Prototypal Inheritance in ColdFusion</a>, which is incidentally one of the topics I talk about in my <a href="http://www.elliottsprehn.com/blog/presentations/i-bet-you-didnt-know-you-could-do-that-with-coldfusion/">I bet you didn&#8217;t know you could do that with ColdFusion</a> presentation, which I gave at BFusion 2008 and will be doing an updated version of at <a href="http://cfunited.com/2010/">CFUnited 2010</a>. &lt;/shameless-plug&gt;</p>
<p>The code samples have a Prototype.cfc and some examples that use complete objects as the prototype like with JS.</p>
<pre class="brush:coldfusion">
user = createObject("component","User").init();
admin = createObject("component","Admin").init();
admin.setPrototype(user);

me = admin.new();
me.setName("Elliott Sprehn");

// Somewhere off in plugin land...
function toXML() {
	return "
		<user id='#this.getId()#'>
			<name>#this.getName()#</name>
		</user>";
}
user.toXML = toXML;

// In the application's code
writeOutput( me.toXML() );
/*
	<user id="1">
		<name>Elliott Sprehn</name>
	</user>
*/
</pre>
<p>One reason I really like this is that it lets you arbitrarily extend the model in plugins without impacting object creation performance.</p>
<p>There&#8217;s a tendency to go crazy with the Factory pattern and then broadcast lots of events (transfer takes this approach with actionAfterNewTransferEvent and friends). Unfortunately it makes object creation slower and slower since each create has to notify more and more listeners.</p>
<p>The Eclipse IDE ran into this problem and called it the &#8220;event storm&#8221; where a single mouse click might fire thousands of events and make the whole IDE seem slow.</p>
<p>Using prototypal inheritance we can pre-compute the entire prototype chain and all the complex object state so that each object create only needs one extra setPrototype().</p>
<p>Thinking outside the traditional class based object approach can solve many future problems and make your life easier. Whether it be by using function pointers creatively or something even less conventional like prototypal inheritance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2010/03/24/using-prototypal-inheritance-in-coldfusion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ColdFusion Mappings and Relative Paths</title>
		<link>http://www.elliottsprehn.com/blog/2010/02/19/coldfusion-mappings-and-relative-paths/</link>
		<comments>http://www.elliottsprehn.com/blog/2010/02/19/coldfusion-mappings-and-relative-paths/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 09:56:57 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/?p=69</guid>
		<description><![CDATA[Recently one of our applications started failing inconsistently with strange errors about certain files not existing. We&#8217;d see error emails about things like the /myapplication/views/pages/survey.cfm not existing which didn&#8217;t make any sense since /myapplication is a mapping created inside the Application.cfc &#60;cfset this.mappings["/myapplication"] = expandPath("../")&#62; See the bug there? ExpandPath() is relative to the requested [...]]]></description>
			<content:encoded><![CDATA[<p>Recently one of our applications started failing inconsistently with strange errors about certain files not existing. We&#8217;d see error emails about things like the <code>/myapplication/views/pages/survey.cfm</code> not existing which didn&#8217;t make any sense since /myapplication is a mapping created inside the Application.cfc</p>
<pre class="brush: coldfusion">
&lt;cfset this.mappings["/myapplication"] = expandPath("../")&gt;
</pre>
<p>See the bug there? ExpandPath() is relative to the requested template. This application had previously had all requests routed through <code>/public/index.cfm</code> so the mapping worked fine.</p>
<p>However, recently we had added some new web services like <code>/public/services/ScheduleService.cfc</code> and now whenever an Ajax request went through the CF mapping would change from pointing to <code>/</code> to <code>/public</code> causing all other concurrent requests to fail with confusing missing file errors.</p>
<p>I fixed this by making sure the path was no longer relative.</p>
<pre class="brush: coldfusion">
&lt;cfset this.mappings["/myapplication"] =
   getDirectoryFromPath(getCurrentTemplatePath())&gt;
</pre>
<p>So the moral of the story is to <strong>NEVER</strong> use expandPath() to create a mapping that&#8217;s relative to the webroot.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2010/02/19/coldfusion-mappings-and-relative-paths/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion arguments.callee</title>
		<link>http://www.elliottsprehn.com/blog/2009/07/16/coldfusion-argumentscallee/</link>
		<comments>http://www.elliottsprehn.com/blog/2009/07/16/coldfusion-argumentscallee/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 17:33:48 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/2009/07/16/coldfusion-argumentscallee/</guid>
		<description><![CDATA[Last night Ben Nadel sent me an email asking if there was any way to get the currently executing function so you could get the metadata from it. &#60;cffunction name="test" myAttribute="1"&#62; &#60;--- How can we get the myAttribute value? ---&#62; &#60;/cffunction&#62; The first obvious attempt at this is to use getMetaData(test).myAttribute, and that works fine [...]]]></description>
			<content:encoded><![CDATA[<p>Last night Ben Nadel sent me an email asking if there was any way to get the currently executing function so you could get the metadata from it.</p>
<pre class="brush: coldfusion">&lt;cffunction name="test" myAttribute="1"&gt;
  &lt;--- How can we get the myAttribute value? ---&gt;
&lt;/cffunction&gt;</pre>
<p>The first obvious attempt at this is to use <code>getMetaData(test).myAttribute</code>, and that works fine until you pass the function as a pointer and then it&#8217;s not called <em>test</em> anymore. Instead we need a different way to get the current function.</p>
<p>I had looked into this for implementing closures some time ago, and even talked about this at BFusion 2008. My original workaround was to create an API around the function pointer. For example <em>executeFunction</em>(func) that passes the function pointer in as an argument. Unfotunately, this also means you can&#8217;t just pass this function around transparently to anything that expects a function pointer.</p>
<p>Last night, however, I had a eureka moment and figured this one out. To get a reference to the current function we&#8217;re going to harness exceptions and the information we can get from the stack.</p>
<pre class="brush: coldfusion">&lt;cffunction name="getStackFunction" access="public" returntype="any" output="false"&gt;
   &lt;cfargument name="name" type="string" required="true"&gt;
   &lt;cfargument name="depth" type="numeric" required="false" default="1"&gt;

   &lt;cfset var TemplateClassLoader = createObject("java","coldfusion.runtime.TemplateClassLoader")&gt;
   &lt;cfset var servletContext = getPageContext().getServletContext()&gt;
   &lt;cfset var templatePath = ""&gt;
   &lt;cfset var TemplateClass = ""&gt;
   &lt;cfset var field = ""&gt;

   &lt;cftry&gt;
      &lt;cfthrow type="Exception"&gt;

   &lt;cfcatch type="any"&gt;
      &lt;cfset templatePath = cfcatch.tagContext[depth+1].template&gt;
   &lt;/cfcatch&gt;
   &lt;/cftry&gt;

   &lt;cfset TemplateClass = TemplateClassLoader.findClass(servletContext,templatePath)&gt;
   &lt;cfset field = TemplateClass.getDeclaredField(arguments.name)&gt;
   &lt;cfset field.setAccessible(true)&gt;

   &lt;cfreturn field.get(TemplateClass.newInstance())&gt;
&lt;/cffunction&gt;</pre>
<p>We can then use this code with the (<strong>case sensitive</strong>) name of the function in the current stack to get a pointer to that function.</p>
<pre class="brush: coldfusion">&lt;cffunction name="test" myAttribute="1" output="false"&gt;
   &lt;cfargument name="x" type="numeric"&gt;
   &lt;cfset arguments.callee = getStackFunction("test")&gt;
   &lt;cfreturn arguments.x + getMetaData(arguments.callee).myAttribute&gt;
&lt;/cffunction&gt;</pre>
<p>You can use the depth parameter to get functions farther down the stack as well.</p>
<p>I&#8217;ll go over how to build proper closure constructs using this technique, and some other novel ones that don&#8217;t even require runtime magic in an upcoming post.</p>
<p>Oh, and hats off to Ben for sparking my interest in this issue again! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2009/07/16/coldfusion-argumentscallee/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>cfimage and ImageScaleToFit on Large Images Pegs CPU</title>
		<link>http://www.elliottsprehn.com/blog/2009/01/14/cfimage-and-imagescaletofit-on-large-images-pegs-cpu/</link>
		<comments>http://www.elliottsprehn.com/blog/2009/01/14/cfimage-and-imagescaletofit-on-large-images-pegs-cpu/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 11:05:07 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/2009/01/14/cfimage-and-imagescaletofit-on-large-images-pegs-cpu/</guid>
		<description><![CDATA[I was working on the new profile picture feature of the registration and CFUnited 2009 website when I ran into an issue where a user uploaded a 2112 x 2816 (2MB) photo. This seemed to cause file locking issues in cfimage which I was told were addressed by CF 8.0.1 Cumulative Hot Fix 1. I [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on the new profile picture feature of the registration and CFUnited 2009 website when I ran into an issue where a user uploaded a 2112 x 2816 (2MB) photo. </p>
<p>This seemed to cause file locking issues in cfimage which I was told were addressed by CF 8.0.1 Cumulative Hot Fix 1. I applied the hot fix and everything seemed to work, but then when I started testing with the large file again the CPU would jump to 100% and the request would never seem to finish. I tried all kinds of things, and nothing I did seemed to make a difference.</p>
<p>Finally I tried the &#8220;highestPerformance&#8221; interpolation and the requests started finishing hundreds of times faster. Any other interpolation algorithm seems to cause the thread to lock up. </p>
<p>I&#8217;ve fixed this in our code with:</p>
<pre class="brush: coldfusion">&lt;!---
	CF8 will peg the CPU to 100% and this thread will seem
	to hang for minutes on large images if we don't choose
	highestPerformance.
---&gt;
&lt;cfif getSize("kilobytes") gt 375&gt;
	&lt;cfset arguments.interpolation = "highestPerformance"&gt;
&lt;/cfif&gt;
</pre>
<p>What&#8217;s most odd is that the issue only appears on Windows on the production server. On my Macbook I can choose a different algorithm and get a nice resize without hanging the request.</p>
<p>Production server is Java 1.6 u11, CF8.0.1 HF2, Windows Server 2003</p>
<p>Anyone have any ideas?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2009/01/14/cfimage-and-imagescaletofit-on-large-images-pegs-cpu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ColdFusion 8 Exception Handling Breaks HTTP Requests</title>
		<link>http://www.elliottsprehn.com/blog/2007/08/01/coldfusion-8-exception-handling-breaks-http-requests/</link>
		<comments>http://www.elliottsprehn.com/blog/2007/08/01/coldfusion-8-exception-handling-breaks-http-requests/#comments</comments>
		<pubDate>Wed, 01 Aug 2007 06:52:04 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/2007/08/01/coldfusion-8-exception-handling-breaks-http-requests/</guid>
		<description><![CDATA[Just found this bug today&#8230;. So CF8 outputs the cfcatch.message into the Reason-Phrase portion of the HTTP Response, however it does not strip new lines (LF or CR). A web server, however, should never send new lines in the Reason-Phrase [1], and should probably be truncating that error message at a certain length. [1] RFC2616, [...]]]></description>
			<content:encoded><![CDATA[<p>Just found this bug today&#8230;.  </p>
<p>So CF8 outputs the cfcatch.message into the Reason-Phrase portion of the HTTP Response, however it does not strip new lines (LF or CR). A web server, however, should never send new lines in the Reason-Phrase [1], and should probably be truncating that error message at a certain length. </p>
<p>[1] <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html">RFC2616, Section6, HTTP Response</a></p>
<p>It&#8217;s pretty easy to reproduce this bug:</p>
<p><code>&amp;lt;cfthrow message="foo #chr(10)##chr(10)##chr(10)# bar"&amp;gt;</code></p>
<p>Another way to show this is with the new deserializeJSON() function in CF8 when the JSON is not valid. CF outputs the exception message with the JSON into the Reason-Phrase portion of the HTTP response Status-Line without stripping out new lines.</p>
<h3>ColdFusion Code</h3>
<pre class="brush: js">&lt;cfset json = '
{
    "foo": [
        {}
        "",
        {
            "f": {}
        }
    ]
}
'&gt;

&lt;cfset deserializeJSON(json)&gt;</pre>
<p>And the server responds with:</p>
<h3>HTTP Response</h3>
<pre class="brush: plain">HTTP/1.1 500 JSON parsing failure: Expected ',' or ']' at character 20:'"' in {
	"foo": [
		{}
		"",
		{
			"f": {}
		}
	]
}
Date: Wed, 01 Aug 2007 05:31:39 GMT
Server: Apache/1.3.33 (Darwin) mod_fastcgi/2.4.2 PHP/5.2.0 JRun/4.0
server-error: true
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

&lt;!-- " ---&gt;&lt;/TD&gt;&lt;/TD&gt;&lt;/TD&gt;&lt;/TH&gt;&lt;/TH&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;/TR&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/TABLE&gt;</pre>
<p>As it stands now, if you had <strong>100</strong> lines of JSON and there&#8217;s an error at the end, CF will dump <strong>all previous lines</strong> of JSON into the http Reason-Phrase.</p>
<p>This is particularly apparent in Safari (and WebKit based browsers) where it actually displays the HTTP headers in the body of the page because it sees new lines and assumes the HTTP headers are complete, and worse in Gecko based browsers that render the page as text/plain because the Content-Type header is never processed!</p>
<p>It should also be noted that CF7 output &#8220;Internal Server Error&#8221; for the Reason-Phrase instead of the exception message.</p>
<p>There also seems to be some other random junk thrown into the page when an exception is thrown&#8230;.</p>
<pre class="brush: coldfusion">foo bar baz&lt;cfthrow message="foo #chr(10)##chr(10)#bar"&gt;</pre>
<p>Will generate the following right after the http headers:</p>
<pre class="brush: plain">b
foo bar baz
1f27
</pre>
<p>I hope this saves someone some time trying to figure out what&#8217;s going on on their code! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2007/08/01/coldfusion-8-exception-handling-breaks-http-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting the Expected Results for GetCurrentTemplatePath() in a Custom Tag.</title>
		<link>http://www.elliottsprehn.com/blog/2007/07/17/getting-the-expected-results-for-getcurrenttemplatepath-in-a-custom-tag/</link>
		<comments>http://www.elliottsprehn.com/blog/2007/07/17/getting-the-expected-results-for-getcurrenttemplatepath-in-a-custom-tag/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 21:43:39 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.elliottsprehn.com/blog/2007/07/17/getting-the-expected-results-for-getcurrenttemplatepath-in-a-custom-tag/</guid>
		<description><![CDATA[While working on the template system used for the conference websites I ran across a problem where I needed the path to the template that called a custom tag. The first thing I tried was getCurrentTemplatePath() thinking that it might return that since the documentation makes no mention of custom tags. Instead, however, the function [...]]]></description>
			<content:encoded><![CDATA[<p>While working on the template system used for the <a href="http://cfunited.com">conference websites</a> I ran across a problem where I needed the path to the template that called a custom tag. The first thing I tried was getCurrentTemplatePath() thinking that it might return that since the documentation makes no mention of custom tags. Instead, however, the function returns the path to the custom tag itself.</p>
<p><a href="http://www.bennadel.com/">Ben Nadel</a> noticed some of this <a href="http://www.bennadel.com/blog/828-Dynamic-And-Unexpected-ColdFusion-GetCurrentTemplatePath-Behavior.htm">odd behavior</a> as well.</p>
<p>I spent a long time trying to figure out how to get the caller template path, including what Ben did which was to add a special function to the caller scope.</p>
<pre class="brush: coldfusion">&lt;cfscript&gt;
function getCallerTemplatePath() {
    return getCurrentTemplatePath();
}
caller.getCallerTemplatePath = getCallerTemplatePath;
path = caller.getCallerTemplatePath();
&lt;/cfscript&gt;</pre>
<p>This doesn&#8217;t work though. Instead I still got the template path of the custom tag!</p>
<p>I dug around in the PageContext (which is returned from getPageContext() if you&#8217;re not familiar) with no luck and finally gave up resorting to this&#8230;</p>
<pre class="brush: js">/**
    Monumental hack, but the only way I could figure out how to do
    a getCurrentTemplatePath() like call that resolves to the page
    that called this custom tag.
*/
function getCallerTemplatePath() {
    try {
       error;
    } catch( any cfcatch ) {
        return cfcatch.tagContext[3].template;
    }
}</pre>
<p>Which worked but really felt like a hack since it means throwing an exception on every request. So I kept an eye out as I dug around in the internals of the CF engine for various other things, and today I was rewarded with an awesome solution.</p>
<pre class="brush: js">/** Gets the path to the page that called this custom tag. */
function getCallerTemplatePath() {
    var field = getMetaData(caller).getDeclaredField("pageContext");
    field.setAccessible(true);
    return field.get(caller).getPage().getCurrentTemplatePath();
}</pre>
<p>Now to get at why and how this kind of thing works&#8230;</p>
<p>Inside the ColdFusion runtime the foundation unit for all scripts, components and tags is the <code>coldfusion.runtime.CFPage</code> object, and the getCurrentTemplatePath() function is really identical to&#8230;</p>
<pre class="brush: js">function getCurrentTemplatePath() {
    return getPageContext().getPage().getCurrentTemplatePath();
}</pre>
<p>After realizing this it dawned on me that the custom tags, cfcs, and pages all have their own PageContext and Page objects, and as such the template path is going to be different, or rather bound, to the page in which the function is called from, not where it&#8217;s defined.</p>
<p>Knowing this I was able to grab the page context out of the caller scope, which is the page context of the caller, and not the current page, and use that to get the current template path of the page for which that page context operates.</p>
<p>Also, for those who aren&#8217;t familiar, the getMetaData() function can be used to return the java.lang.Class instance for most objects you wouldn&#8217;t normally be able to call getClass() on in ColdFusion. For instance you can call <code>getMetaData(variables).getName()</code> and you&#8217;ll get <code>coldfusion.runtime.VariableScope</code>.</p>
<p>Doing this really made my code feel less icky, so I hope this is useful to someone else.</p>
<p>(PS, Tested and works on CF6+ and CF7+, anyone have CF8?)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elliottsprehn.com/blog/2007/07/17/getting-the-expected-results-for-getcurrenttemplatepath-in-a-custom-tag/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	<img style='margin:0;padding:0;border:0;' width='1px' height='1px' src="http://www.elliottsprehn.com/blog/wp-content/plugins/mystat/mystat.php?act=time_load&id=34547&rnd=562484193" /></channel>
</rss>
