<?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>gregs &#187; ColdFusion</title>
	<atom:link href="http://gregs.tcias.co.uk/category/comps/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://gregs.tcias.co.uk</link>
	<description>helping me remember what I figure out</description>
	<lastBuildDate>Sun, 13 Jun 2010 02:16:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AJAX calls and expired sessions</title>
		<link>http://gregs.tcias.co.uk/2008/06/19/ajax-calls-and-expired-sessions/</link>
		<comments>http://gregs.tcias.co.uk/2008/06/19/ajax-calls-and-expired-sessions/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 08:12:44 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://gregs.teacupinastorm.com/?p=477</guid>
		<description><![CDATA[I have been updating a bunch of code recently to make use of the new features in Prototype 1.6 and one of the great additions in this release was the introduction of Automatic JavaScript response evaluation. This allowed me to improve on my session checking code without having to fuff around with the response information [...]]]></description>
			<content:encoded><![CDATA[<p>I have been updating a bunch of code recently to make use of the new features in <a href="http://prototypejs.org/">Prototype 1.6</a> and one of the great additions in this release was the introduction of <a href="http://prototypejs.org/api/ajax/request">Automatic JavaScript response evaluation</a>. This allowed me to improve on my session checking code without having to fuff around with the response information sent back to the client. The problem was with XHR requests: i.e. if the user initiated such a request when his session had expired, then usually the response would fail or worse just hang.</p>
<p>The snippet below shows my new session checking code.</p>
<div class="igBar"><span id="ljavascript-4"><a href="#" onclick="javascript:showPlainTxt('javascript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-4">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script type=<span style="color: #3366CC;">"text/javascript"</span>&gt;&lt;!--</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> myAjaxCall<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;url = <span style="color: #3366CC;">"index.cfm"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;pars=<span style="color: #3366CC;">"?fuseaction.someFuseaction&amp;par1=1&amp;par2=2"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #006600;">Updater</span><span style="color: #66cc66;">&#40;</span>\\<span style="color: #3366CC;">'div_to_populate<span style="color: #000099; font-weight: bold;">\\</span>'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;url, <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;method: \\<span style="color: #3366CC;">'post<span style="color: #000099; font-weight: bold;">\\</span>'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;postBody: pars,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;onLoading: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #009900; font-style: italic;">//code to run while making the request</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;onComplete : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>transport,json<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>json &amp;&amp; json<span style="color: #66cc66;">&#91;</span>\\<span style="color: #3366CC;">'session<span style="color: #000099; font-weight: bold;">\\</span>'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;setSessionExpired<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Code to run when the request has completed</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;onFailure: <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>\\<span style="color: #3366CC;">'something went wrong<span style="color: #000099; font-weight: bold;">\\</span>'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; evalScripts:<span style="color: #003366; font-weight: bold;">true</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> setSessionExpired<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;<span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>\\<span style="color: #3366CC;">'Your session has timed out<span style="color: #000099; font-weight: bold;">\\</span>'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;window.<span style="color: #006600;">location</span>=\\<span style="color: #3366CC;">'http://&lt;cfoutput&gt;#cgi.HTTP_HOST#&lt;/cfoutput&gt;/?fuseaction=home.home<span style="color: #000099; font-weight: bold;">\\</span>'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// --&gt;&lt;/script&gt; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The trick is to intercept the call when you do your session checking at the back end. Let's say you have a fuseaction called login.login (see below and yes this is fusebox 3 :S) where you display the login form when a user is not logged in, this is where I inserted the check for an XHR request, by looking at the http headers sent along with the request. The key here is a new header attribute passed in with Prototype "X-Requested-With". If this attribute exists then I know it's an XHR request and I can create a custom JSON header with an error struct that holds a key called session with a value of timeout. All I then need to do is encode the struct as JSON and pass that encoded struct back to the browser.</p>
<div class="igBar"><span id="lcode-5"><a href="#" onclick="javascript:showPlainTxt('code-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-5">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;cfcase value=<span style="color:#CC0000;">"login"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;!--- gvs 1Feb08 - handles XHR requests that session timeout ---&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfset attributes.<span style="">request</span> = GetHttpRequestData<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfif StructKeyExists<span style="color:#006600; font-weight:bold;">&#40;</span>attributes.<span style="">request</span>.<span style="">headers</span>,<span style="color:#CC0000;">"X-Requested-With"</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfsetting showdebugoutput=<span style="color:#CC0000;">"false"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfparam name=<span style="color:#CC0000;">"attributes.jsonObj"</span> default=<span style="color:#CC0000;">"#CreateObject('component','com.jehiah.json')#"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfparam name=<span style="color:#CC0000;">"error"</span> default=<span style="color:#CC0000;">"#StructNew()#"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfset error<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0000;">'session'</span><span style="color:#006600; font-weight:bold;">&#93;</span>=<span style="color:#CC0000;">'timeout'</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfif StructKeyExists<span style="color:#006600; font-weight:bold;">&#40;</span>attributes,<span style="color:#CC0000;">"jsonObj"</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfheader name=<span style="color:#CC0000;">"X-JSON"</span> value=<span style="color:#CC0000;">"#trim(attributes.jsonObj.encode(error))#"</span> /&gt;&lt;cfabort&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/cfif&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/cfif&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfif StructKeyExists<span style="color:#006600; font-weight:bold;">&#40;</span>session,<span style="color:#CC0000;">'login'</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfset attributes.<span style="">login</span> = session.<span style="">login</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfelse&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfparam name=<span style="color:#CC0000;">"attributes.login"</span> default=<span style="color:#CC0000;">""</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/cfif&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfscript&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xfa.<span style="">submitform</span>=<span style="color:#CC0000;">'index.cfm?fuseaction=login.processlogin'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/cfscript&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfinclude template=<span style="color:#CC0000;">"#affiliate('dsp_login.cfm')#"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/cfcase&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now let's jump back to the JavaScript code and take a look at the onComplete function again:</p>
<div class="igBar"><span id="ljavascript-6"><a href="#" onclick="javascript:showPlainTxt('javascript-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-6">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">onComplete : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>transport,json<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>json &amp;amp;&amp;amp; json<span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">'session'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setSessionExpired<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Code to run when the request has completed</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>If there's a JSON object and it has a key of session then I call my setSessionExpired function which redirects the users. Now the json session key only exists in these situations since the call normally just passes back the result of the call.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2008/06/19/ajax-calls-and-expired-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stubbie 0.1 available for download</title>
		<link>http://gregs.tcias.co.uk/2007/05/04/stubbie-01-available-for-download/</link>
		<comments>http://gregs.tcias.co.uk/2007/05/04/stubbie-01-available-for-download/#comments</comments>
		<pubDate>Fri, 04 May 2007 01:48:30 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://gregs.teacupinastorm.com/?p=452</guid>
		<description><![CDATA[Just wanted to let folks know, and with trepidation, that the 0.1 release of Stubbie is available for download from the project page. I have also added a few blog posts to the project:

Basic install instructions
Links for feedback, issues and suggestions

]]></description>
			<content:encoded><![CDATA[<p>Just wanted to let folks know, and with trepidation, that the 0.1 release of Stubbie is available for download from <a title="Stubbie project page" href="http://stubbie.riaforge.org/">the project page</a>. I have also added a few blog posts to the project:</p>
<ul>
<li><a title="Basic install instructions" href="http://stubbie.riaforge.org/blog/index.cfm/2007/5/3/Installing-and-using-Stubbie">Basic install instructions</a></li>
<li><a title="Download Stubbie" href="http://stubbie.riaforge.org/blog/index.cfm/2007/5/3/Download-Stubbie">Links for feedback, issues and suggestions</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2007/05/04/stubbie-01-available-for-download/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing project: Stubbie</title>
		<link>http://gregs.tcias.co.uk/2007/04/24/announcing-project-stubbie/</link>
		<comments>http://gregs.tcias.co.uk/2007/04/24/announcing-project-stubbie/#comments</comments>
		<pubDate>Tue, 24 Apr 2007 02:12:39 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://gregs.teacupinastorm.com/?p=449</guid>
		<description><![CDATA[Just a quick note to let folks know that I have created a small project on RIA Forge called Stubbie. Inspired by a feature in Rails, Stubbie basically creates a set of test stubs for your apps CFCs. I have set up specific blog for it over at RIA forge to keep everything in one [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to let folks know that I have created a small project on <a href="http://www.riaforge.org/">RIA Forge</a> called <a href="http://stubbie.riaforge.org/">Stubbie</a>. Inspired by a feature in Rails, Stubbie basically creates a set of test stubs for your apps CFCs. I have set up specific blog for it over at RIA forge to keep everything in one place, but will post updates here as well.</p>
<p>Also there's no code yet, still one or two things I need to sort out before I'll make the first 0.1 release.<br />
I'd just like to thank a few people who helped get this project of the ground:</p>
<p>Special thanks must go to Stephen (Spike) Milligan for allowing me to use his CFCDoc code which allowed me to quickly build the project without having to worry about the File System and CFC parsing.</p>
<p>Seth Petry-Johnson also deserves a special mention for allowing me to use his VarScopeChecker.cfc as part of the project so that we can all benefit from a var scope unit test.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2007/04/24/announcing-project-stubbie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedded image</title>
		<link>http://gregs.tcias.co.uk/2007/03/13/embedded-image/</link>
		<comments>http://gregs.tcias.co.uk/2007/03/13/embedded-image/#comments</comments>
		<pubDate>Tue, 13 Mar 2007 04:26:37 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://gregs.teacupinastorm.com/?p=448</guid>
		<description><![CDATA[A client recently decided to start storing all of their images in a database and usually we would point the image source to a cfm page, where we'd do something like this:
PLAIN TEXT
CODE:




request.uploadedPic = application.staffManager.getStaffImage&#40;session.user.getId&#40;&#41;&#41;;


context = getPageContext&#40;&#41;;


context.setFlushOutput&#40;false&#41;;


response = context.getResponse&#40;&#41;.getResponse&#40;&#41;;


out = response.getOutputStream&#40;&#41;;


response.setContentType&#40;"image/jpeg"&#41;;


response.setContentLength&#40;arrayLen&#40;request.uploadedPic&#91;'staffPhoto'&#93;&#91;1&#93;&#41;&#41;;


out.write&#40;request.uploadedPic&#91;'staffPhoto'&#93;&#91;1&#93;&#41;;


out.flush&#40;&#41;;


response.reset&#40;&#41;;


out.close&#40;&#41;; 






Which worked nicely until I read about some performance issues with http calls and [...]]]></description>
			<content:encoded><![CDATA[<p>A client recently decided to start storing all of their images in a database and usually we would point the image source to a cfm page, where we'd do something like this:</p>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showPlainTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">request.<span style="">uploadedPic</span> = application.<span style="">staffManager</span>.<span style="">getStaffImage</span><span style="color:#006600; font-weight:bold;">&#40;</span>session.<span style="">user</span>.<span style="">getId</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">context = getPageContext<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">context.<span style="">setFlushOutput</span><span style="color:#006600; font-weight:bold;">&#40;</span>false<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">response = context.<span style="">getResponse</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">getResponse</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">out = response.<span style="">getOutputStream</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">response.<span style="">setContentType</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"image/jpeg"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">response.<span style="">setContentLength</span><span style="color:#006600; font-weight:bold;">&#40;</span>arrayLen<span style="color:#006600; font-weight:bold;">&#40;</span>request.<span style="">uploadedPic</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0000;">'staffPhoto'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">out.<span style="">write</span><span style="color:#006600; font-weight:bold;">&#40;</span>request.<span style="">uploadedPic</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0000;">'staffPhoto'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">out.<span style="">flush</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">response.<span style="">reset</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">out.<span style="">close</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Which worked nicely until I read about some <a title="CFDocument performance" href="http://www.webapper.net/index.cfm/2007/2/18/CFDocument-performance">performance issues</a> with http calls and the cfdocument tag. Zac (yes his name pops up a lot in this blog), put me onto directly embedding the image into the source, like such:</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showPlainTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;img src=<span style="color:#CC0000;">"data:image/jpeg;base64,&amp;lt;cfoutput&amp;gt;#BinaryEncode(request.uploadedPic['staffPhoto'][1],'Base64')#&amp;lt;/cfoutput&amp;gt;"</span> alt=<span style="color:#CC0000;">"Embedded Image"</span> /&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No need to make a http call to display the image anymore.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2007/03/13/embedded-image/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Swapping out Batik</title>
		<link>http://gregs.tcias.co.uk/2006/11/09/swapping-out-batik/</link>
		<comments>http://gregs.tcias.co.uk/2006/11/09/swapping-out-batik/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=158</guid>
		<description><![CDATA[A while back I was tinkering with converting SVG output to PNG using Batik, but I was not having much luck with it as it seemed that the Batik jar files that come with CFMX were out of date or plain missing some methods. I gave up, but a colleague of mine, Zac, picked up [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I was tinkering with converting SVG output to PNG using Batik, but I was not having much luck with it as it seemed that the Batik jar files that come with CFMX were out of date or plain missing some methods. I gave up, but a colleague of mine, Zac, picked up the baton and has come up with a solution. Now before you dive in and follow these steps, bare in mind that this is just our first day of using this, so even though Flash forms still appear to be working there may well be cases that we haven't stumbled across yet, where our changes have broken CF (and for the record we don't use Flash Forms, Charts or anything flex related). So in other words use this 'tip' with caution!!</p>
<p>Still reading? Awesome, so here's what we came up with, first off the Batik version that ships with CFMX 7 is 1.5.1, so head over to the <a title="Apache Archive" href="http://archive.apache.org/dist/xml/batik/">Apache Archive</a> and download the 1.5.1 version from the archive. In essence we'll be replacing like for like. Once downloaded locate the the <em>cfforms\jars</em> folder in your CFMX installation (on windows standard you'll find it under C:\CFusionMX7\wwwroot\WEB-INF\cfform\jars).</p>
<p>Before continuing make sure you back up all of the batik files located there (i.e. batik-awt-util.jar, batik-css.jar, batik-ext.jar, batik-transcoder.jar and batik-util.jar) and move them out of the CFMX install folder. Once done, just extract the lib and extensions folder as well as the batik-*.jar files into <em>cfform\jars</em> folder. Once done all you need to do is restart CFMX and the updated JAR files will load (you may want to consider to launch CFMX in debug mode to make sure nothing bad is happening).</p>
<h4>Update</h4>
<p>Barney Boisvert got in touch to let me know that he is done something similar, but used a newer version of Batik. <a title="Barney Blog" href="http://barneyb.com/barneyblog/index.php?s=batik&amp;searchsubmit=Go">Follow the link</a> to see his posts on the topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2006/11/09/swapping-out-batik/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Refreshing web service stubs</title>
		<link>http://gregs.tcias.co.uk/2006/09/22/refreshing-web-service-stubs/</link>
		<comments>http://gregs.tcias.co.uk/2006/09/22/refreshing-web-service-stubs/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=141</guid>
		<description><![CDATA[I have been spending a few days building a bunch of web services for a client, however whenever I made a change to the web service itself the only way I could get that change to be reflected was by either waiting or re-starting cfmx. I did remember a post a while back that showed [...]]]></description>
			<content:encoded><![CDATA[<p>I have been spending a few days building a bunch of web services for a client, however whenever I made a change to the web service itself the only way I could get that change to be reflected was by either waiting or re-starting cfmx. I did remember a post a while back that showed a better way. Finally I had enough today and  went looking for <a title="Refreshing Web Service Stubs in ColdFusion MX" href="http://www.bpurcell.org/blog/index.cfm?mode=entry&amp;entry=965">the solution</a>.</p>
<p>For my own benefit here is the code required to refresh the stub:</p>
<div class="igBar"><span id="lcode-12"><a href="#" onclick="javascript:showPlainTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"> </li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Big thanks once again to <a title="burcell.org " href="http://www.bpurcell.org/">Brandon Purcell</a> for sharing this with us</p>
<h4>Update</h4>
<p>Or I could have just looked in the CF Administrator (if you are using 7.0.1) under Data &amp; Services and looked at the registered web services and refreshed them there...</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2006/09/22/refreshing-web-service-stubs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CFMX and the PowerBookPro</title>
		<link>http://gregs.tcias.co.uk/2006/07/04/cfmx-and-the-powerbookpro/</link>
		<comments>http://gregs.tcias.co.uk/2006/07/04/cfmx-and-the-powerbookpro/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=159</guid>
		<description><![CDATA[A wee while back the Mac PowerBookPros received a JVM update. This brings it up to  version 1.5.06, which is fabulous, but of course stops you from being able to run ColdFusion. Thankfully the JVM upgrade leaves the old versions on your system. The simple trick to get your CFMX installation to wok again [...]]]></description>
			<content:encoded><![CDATA[<p>A wee while back the Mac PowerBookPros received a JVM update. This brings it up to  version 1.5.06, which is fabulous, but of course stops you from being able to run ColdFusion. Thankfully the JVM upgrade leaves the old versions on your system. The simple trick to get your CFMX installation to wok again after the upgrade is to run the start up script from the console with the path to the old JVM like such:</p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo /System/Library/Frameworks/JavaVM.<span style="">framework</span>/Versions/<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">4</span>.<span style="color:#800000;color:#800000;">2</span>/Commands/java -jar /Applications/JRun4/lib/jrun.<span style="">jar</span> -start cfusion &amp;amp; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2006/07/04/cfmx-and-the-powerbookpro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CFMX &#8211; MSDE connection refused error</title>
		<link>http://gregs.tcias.co.uk/2005/12/16/cfmx-msde-connection-refused-error/</link>
		<comments>http://gregs.tcias.co.uk/2005/12/16/cfmx-msde-connection-refused-error/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[MS SQL]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=156</guid>
		<description><![CDATA[I just started using MSDE for local development again and after creating my first DSN through the ColdFusion administrator I encountered the following problem:
PLAIN TEXT
CODE:




# Connection verification failed for data source: SMS


java.sql.SQLException: &#91;Macromedia&#93;&#91;SQLServer JDBC Driver&#93;Error establishing socket. Connection refused: connect


The root cause was that: java.sql.SQLException: &#91;Macromedia&#93;&#91;SQLServer JDBC Driver&#93;Error establishing socket. Connection refused: connect 






First thing [...]]]></description>
			<content:encoded><![CDATA[<p>I just started using MSDE for local development again and after creating my first DSN through the ColdFusion administrator I encountered the following problem:</p>
<div class="igBar"><span id="lcode-17"><a href="#" onclick="javascript:showPlainTxt('code-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-17">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Connection verification failed for data source: SMS</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">java.<span style="">sql</span>.<span style="">SQLException</span>: <span style="color:#006600; font-weight:bold;">&#91;</span>Macromedia<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>SQLServer JDBC Driver<span style="color:#006600; font-weight:bold;">&#93;</span>Error establishing socket. <span style="">Connection</span> refused: connect</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">The root cause was that: java.<span style="">sql</span>.<span style="">SQLException</span>: <span style="color:#006600; font-weight:bold;">&#91;</span>Macromedia<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>SQLServer JDBC Driver<span style="color:#006600; font-weight:bold;">&#93;</span>Error establishing socket. <span style="">Connection</span> refused: connect </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>First thing I checked (well second after making sure I had provided the right connection details) was to see if anything was listening port on port 1433 by using the handy "netstats -a" command. And there wasn't, so a quick Google search turned up<a href="http://www.robisen.com/index.cfm?mode=entry&amp;entry=BE1AB594-55DC-F2B1-F392552E0A41542A"> this gem from Robi Sen</a>. Sadly this tool didn't help me as apparently my version didn't need it, but a comment did point me to <a href="http://support.microsoft.com/kb/841251/" title="How to enable SQL Server connectivity on Windows XP Service Pack 2">a another link</a>. But sadly it didn't help me either, but the comment did give me an idea. When I went to check my network set up for MS SQL server, sure enough TCP/IP was not listed... What followed was a moment of banging my head sharply on the table.</p>
<p>Right changes applied, restarted the server, verify connection and...</p>
<div class="igBar"><span id="lcode-18"><a href="#" onclick="javascript:showPlainTxt('code-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-18">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Connection verification failed for data source: SMS</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">java.<span style="">sql</span>.<span style="">SQLException</span>: <span style="color:#006600; font-weight:bold;">&#91;</span>Macromedia<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>SQLServer JDBC Driver<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>SQLServer<span style="color:#006600; font-weight:bold;">&#93;</span>Login failed for user <span style="color:#CC0000;">'hermes'</span>. <span style="">Reason</span>: Not associated with a trusted SQL Server connection.</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">The</span> root cause was that: java.<span style="">sql</span>.<span style="">SQLException</span>: <span style="color:#006600; font-weight:bold;">&#91;</span>Macromedia<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>SQLServer JDBC Driver<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>SQLServer<span style="color:#006600; font-weight:bold;">&#93;</span>Login failed for user <span style="color:#CC0000;">'yourUsername'</span>. <span style="">Reason</span>: Not associated with a trusted SQL Server connection. </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Well this one only took a few seconds to fix: <a href="http://www.banmanpro.com/support/sql2k.asp" title="Login Failed for User 'BanManProSQL', Not Associated with a trusted SQL Server Connection.">Windows Authentication only was enabled</a>! Simply open the properties of your server once more, check the security tab and you should see that the option for Windows Authentication is selected. Just change that to SQL server and Windows and you are ready to go...</p>
<p>I guess this is very much a case of damned if you do and damned if you don't for Microsoft as they seemed to have tightened up the security for MS SQL server (I won't even go into the nuisance of trying to install MSDE and being prompted to set an SA password before starting with no indication how to do so), but surely we should be given the option at install time to set these things? Or maybe it's just the MSDE?</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2005/12/16/cfmx-msde-connection-refused-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Checking your free memory</title>
		<link>http://gregs.tcias.co.uk/2005/10/21/checking-your-free-memory/</link>
		<comments>http://gregs.tcias.co.uk/2005/10/21/checking-your-free-memory/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=153</guid>
		<description><![CDATA[Here is a handy little script that I stumbled across a while back (probably on a mailing list), sorry I can't remember who posted it, but for posterity here it is:
PLAIN TEXT
CODE:




&#60;cfscript&#62;


rt = createObject&#40;"Java", "java.lang.Runtime"&#41;;


freemem=rt.getruntime&#40;&#41;.freeMemory&#40;&#41;;


maxmem=rt.getruntime&#40;&#41;.maxMemory&#40;&#41;;


usepercent=freemem/maxmem;


&#60;/cfscript&#62;


&#60;cfoutput&#62; &#60;/cfoutput&#62;


&#60;table&#62;


&#60;tr&#62;


&#60;td&#62;Free memory&#60;/td&#62;


&#60;td align="right"&#62;#numberformat&#40;freemem&#41;#&#60;/td&#62;


&#60;/tr&#62;


&#60;tr&#62;


&#60;td&#62;Max memory&#60;/td&#62;


&#60;td align="right"&#62;#numberformat&#40;maxmem&#41;#&#60;/td&#62;


&#60;/tr&#62;


&#60;/table&#62;


Percent use: #numberformat&#40;usepercent * 100&#41;# 






UPDATE
It was from Pete Freitag's site that I gleaned this tid [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a handy little script that I stumbled across a while back (probably on a mailing list), sorry I can't remember who posted it, but for posterity here it is:</p>
<div class="igBar"><span id="lcode-20"><a href="#" onclick="javascript:showPlainTxt('code-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-20">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;cfscript&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rt = createObject<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"Java"</span>, <span style="color:#CC0000;">"java.lang.Runtime"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">freemem=rt.<span style="">getruntime</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">freeMemory</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">maxmem=rt.<span style="">getruntime</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">maxMemory</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">usepercent=freemem/maxmem;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/cfscript&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;cfoutput&gt; &lt;/cfoutput&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;table&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;tr&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;td&gt;Free memory&lt;/td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;td align=<span style="color:#CC0000;">"right"</span>&gt;#numberformat<span style="color:#006600; font-weight:bold;">&#40;</span>freemem<span style="color:#006600; font-weight:bold;">&#41;</span>#&lt;/td&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;tr&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;td&gt;Max memory&lt;/td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;td align=<span style="color:#CC0000;">"right"</span>&gt;#numberformat<span style="color:#006600; font-weight:bold;">&#40;</span>maxmem<span style="color:#006600; font-weight:bold;">&#41;</span>#&lt;/td&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/table&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Percent use: #numberformat<span style="color:#006600; font-weight:bold;">&#40;</span>usepercent * <span style="color:#800000;color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span># </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>UPDATE</h4>
<p>It was from <a href="http://www.petefreitag.com/item/115.cfm" title="ColdFusion Memory Usage Stats">Pete Freitag's site</a> that I gleaned this tid bit of information and Niklas over at Primsix was kind enough to also point out that he put together <a href="http://www.prismix.com/blog/archives/2005/08/coldfusion_memo.cfm" title="ColdFusion Memory Usage Stats (Revisited)">a graphical version</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2005/10/21/checking-your-free-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create IIS mappings for coldfusion</title>
		<link>http://gregs.tcias.co.uk/2000/10/18/how-to-create-iis-mappings-for-coldfusion/</link>
		<comments>http://gregs.tcias.co.uk/2000/10/18/how-to-create-iis-mappings-for-coldfusion/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=294</guid>
		<description><![CDATA[Just the other day I installed Cold Fusion Enterprise on one of our web servers hosted externally. After the re-boot I fired up a browser to test the installation. Alas the server wouldn't execute .cfm file extensions, instead offering me the chance to download these. The problem was down to the installation program not mapping [...]]]></description>
			<content:encoded><![CDATA[<p>Just the other day I installed Cold Fusion Enterprise on one of our web servers hosted externally. After the re-boot I fired up a browser to test the installation. Alas the server wouldn't execute <em>.cfm</em> file extensions, instead offering me the chance to download these. The problem was down to the installation program not mapping <em>.cfm</em> extensions to the <strong>Application settings</strong>. You can check the mappings and fix this by carrying out the following steps:</p>
<ol>
<li>Start up IIS MMC.</li>
<li>Right click on your site and select <strong>Properties</strong>.</li>
<li>Change to Home Directory, and in the <strong>Application settings</strong> box, click on the configuration button.</li>
<li>Under the <strong>Add mapping</strong> tab yo can see all the file extensions that your server can interpret. If <em>.cfm</em> is not listed, this is the reason your server s not executing the Cold Fusion templates.</li>
<li>Click on the <strong>Add</strong> button and complete the dialogue. Under executable specify the path and file name for your CF server executable, usually <em>&lt;drive letter&gt;:CFUSION\Bin\iscf.dll</em>. Next specify the file extension, i.e. <em>.cfm</em> and make sure that the option for <strong>Scrip engine</strong> is ticked.</li>
</ol>
<p>Repeat the same step for the file extension <em>.dbm</em>, if it's not listed either. Once done click on OK and OK again to return to the console. Fire up your browser and try it again. The files should now execute.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2000/10/18/how-to-create-iis-mappings-for-coldfusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
