I ran into some trouble this week attaching my JSON Exception Handling to a new ColdFusion feature. Specifically, there was content from that page that survived the CFCONTENT reset tag. Instead of valid JSON, my page was outputting the following:

<title>Notes</title> { 
   "error": "blah",

I tracked down the resilient TITLE tag to a CFHTMLHEAD tag. I have never explicitly used this tag, but I learned that it's used to explicitly include page content in the HEAD tag of your page. It can even function retroactively, ie after the HEAD tag has appeared in your code. That's provided that you have not called CFFLUSH, I suppose.

In any case, it was a simple fix. Though there is no way to reset that buffer in ColdFusion, you can easily call out to the servlet page context.

 function resetCFHtmlHead() {
  var out = getPageContext().getOut();
  var method = out.getClass().getDeclaredMethod("initHeaderBuffer",arrayNew(1));

I'm currently working at NerdWallet, a startup in San Francisco trying to bring clarity to all of life's financial decisions. We're hiring like crazy. Hit me up on Twitter, I would love to talk.

Follow @chase_seibert on Twitter