<?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>Simon Whatley &#187; WEB-INF/lib folder</title>
	<atom:link href="http://www.simonwhatley.co.uk/tag/web-inflib-folder/feed" rel="self" type="application/rss+xml" />
	<link>http://www.simonwhatley.co.uk</link>
	<description>The opposite of every great idea is another great idea</description>
	<lastBuildDate>Wed, 02 Nov 2011 09:28:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Eliminating Whitespace in ColdFusion</title>
		<link>http://www.simonwhatley.co.uk/eliminating-whitespace-in-coldfusion</link>
		<comments>http://www.simonwhatley.co.uk/eliminating-whitespace-in-coldfusion#comments</comments>
		<pubDate>Fri, 26 Oct 2007 09:29:35 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Application Servers]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdFusion Administrator]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[page processing]]></category>
		<category><![CDATA[servlets]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[WAP]]></category>
		<category><![CDATA[web application]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[WEB-INF folder]]></category>
		<category><![CDATA[WEB-INF/lib folder]]></category>
		<category><![CDATA[web.xml]]></category>
		<category><![CDATA[web.xml file]]></category>
		<category><![CDATA[whitespace]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=351</guid>
		<description><![CDATA[ColdFusion has never satisfactorily removed whitespace from generated content, however, removing this whitespace can dramatically improve your website's performance. Take a 100KB page for example. If 20% of the page is made up of whitespace, that is 20% that is unneccessary and 20% bandwidth cost that can be saved.]]></description>
			<content:encoded><![CDATA[<p>ColdFusion has never satisfactorily removed whitespace from generated content, however, removing this whitespace can dramatically improve your website&#8217;s performance. Take a 100KB page for example. If 20% of the page is made up of whitespace, that is 20% that is unneccessary and 20% bandwidth cost that can be saved.</p>
<p>Currently there are two main ways a ColdFusion developer can prevent whitespace; via the ColdFusion Administrator and by including certain tags in their code:</p>
<p><strong>1. ColdFusion Administrator</strong></p>
<p>Under the <em>Server Settings &gt; Settings</em> menu item there is a checkbox called &#8216;Enable Whitespace Management&#8217;. This checkbox should always be checked. According to the description, checking this checkbox <em>&#8220;reduces the file size of the pages that ColdFusion returns to the browser by removing many of the extra spaces, tabs, and carriage returns that ColdFusion might otherwise persist from the CFML source file.&#8221;</em> I am yet to be convinced, but it is worthwhile enabling it.</p>
<p><strong>2. ColdFusion Tags</strong></p>
<p><code>&lt;cfsetting enablecfoutputonly="true"&gt;&lt;/cfsetting&gt;</code></p>
<p>The <code>cfsetting</code> tag controls aspects of page processing, such as the output of <acronym title="HyperText Markup Language">HTML</acronym> code in pages (inside and outside the <code>cfsetting</code> tag body). If <code>enablecfoutputonly</code> is set to <code>true</code>, <acronym title="HyperText Markup Language">HTML</acronym> output is blocked if it is not wrapped in a <code>cfoutput</code> tag. Therefore, this tag &#8216;can&#8217; be used to minimise the amount of generated whitespace.</p>
<p><code>&lt;cfsilent&gt;&lt;/cfsilent&gt;</code></p>
<p>The <code>cfsilent</code> tag supresses output produced by <acronym title="ColdFusion Markup Language">CFML</acronym> within a tag&#8217;s scope. Therefore, you simply need to wrap the tag around anything you don&#8217;t want to output to the browser. As it does not return anything from with in it, so you have to be a little be careful when debugging.</p>
<p><code>&lt;cfprocessingdirective supresswhitespace="true"&gt;&lt;/cfprocessingdirective&gt;</code></p>
<p>One of the <code>cfprocessingdirective</code>&#8216;s purposes is to remove excess whitespace from ColdFusion generated content in the tag body. However, it does not affect any whitespace in <acronym title="HyperText Markup Language">HTML</acronym> code. You can nest the tags and toggle <code>supresswhitespace</code> on and off, not that I ever identify a good reason to do so.</p>
<p><strong>But there is a little known third way, using a servlet filter called Trim Filter.</strong></p>
<p>Servlet filters are tools available to web application developers. They are designed to be able to manipulate a request and response (or both) that is sent to a web application.</p>
<p>Trim Filter lets you decrease the size of file your server will send to all clients. The filter removes extra spaces and line breaks from outputted documents. This can be especially useful for <acronym title="Wireless Application Protocol">WAP</acronym>/<acronym title="Wireless Markup Language">WML</acronym> developers working with mobile devices, where the size for transferred documents is limited.</p>
<p>S<strong>etting up the servlet filter in ColdFusion</strong></p>
<p>Using the Trim Filter servlet filter found at the following URL:</p>
<p><a rel="nofollow" href="http://www.servletsuite.com/servlets/trimflt.htm" title="TrimFilter jar File">http://www.servletsuite.com/servlets/trimflt.htm</a></p>
<ul>
<li>Download the <a rel="nofollow" href="http://www.servletsuite.com/servlets/trimflt.jar" title="trimflt.jar">trimflt.jar</a></li>
<li>Save trimflt.jar in the WEB-INF/lib folder in the ColdFusion Server wwwroot.</li>
<li>Edit the web.xml file in the WEB-INF folder in the ColdFusion Server wwwroot with the following code:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;filter-mapping&gt;
	&lt;filter-name&gt;trimFilter&lt;/filter-name&gt;
	&lt;url-pattern&gt;*.cfm&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
&nbsp;
&lt;filter&gt;
	&lt;filter-name&gt;trimFilter&lt;/filter-name&gt;
	&lt;filter-class&gt;com.cj.trim.trimFilter&lt;/filter-class&gt;
&lt;/filter&gt;</pre></div></div>

<ul>
<li>Restart the ColdFusion Service</li>
</ul>
<p>And now, when a ColdFusion page is invoked, the whitespace is suppressed and wow does it do a good job.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/eliminating-whitespace-in-coldfusion/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Poor Man&#039;s HTTP Compression with ColdFusion</title>
		<link>http://www.simonwhatley.co.uk/poor-mans-http-compression-with-coldfusion</link>
		<comments>http://www.simonwhatley.co.uk/poor-mans-http-compression-with-coldfusion#comments</comments>
		<pubDate>Sat, 17 Mar 2007 15:11:23 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Application Servers]]></category>
		<category><![CDATA[Coldbeans]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HTTP protocol]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Server Side]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[web application]]></category>
		<category><![CDATA[web applications]]></category>
		<category><![CDATA[Web Browser]]></category>
		<category><![CDATA[Web Servers]]></category>
		<category><![CDATA[WEB-INF folder]]></category>
		<category><![CDATA[WEB-INF/lib folder]]></category>
		<category><![CDATA[web.xml]]></category>
		<category><![CDATA[web.xml file]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=260</guid>
		<description><![CDATA[Almost every web application will benefit from the compression of content. A compression filter optimises the size of the content that is sent from a webserver to a web browser via the Internet. Since generating content and serving pages via the World Wide Web is the core behind web applications, it is simple components that aid these processes that are incredibly useful. This is where servlet filters come into play.]]></description>
			<content:encoded><![CDATA[<p>An interesting article I read in the CFDJ recently was entitled Poor Man&#8217;s HTTP Compression with ColdFusion. Almost every web application will benefit from the compression of content. A compression filter optimises the size of the content that is sent from a webserver to a web browser via the Internet. Since generating content and serving pages via the World Wide Web is the core behind web applications, it is simple components that aid these processes that are incredibly useful. This is where servlet filters come into play.</p>
<p>Servlet filters are tools available to web application developers. They are designed to be able to manipulate the request and responses that are sent to a web application, without manipulating the servlets, static pages like HTML and, in this case, CFM pages that are being used by the web application (unless of course that is the desired response). Servlet filters act like a chain of steps that a request and response must go through before reaching the page in the application.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3>Compressing Content Using a Servlet Filter</h3>
<p>Compression is a process that reduces the number of bytes required to define a document in order to save disk space or transmission time. It is extremely useful for sending information across the web, because the speed at which people receive information from a web application is dependent upon how much data you are trying to send. The smaller the amount of information that is to be sent, the faster it can be sent. Therefore, compression and the associated responsiveness is a key component to retaining users and generating revenue from those retained users.</p>
<p>Compression can be effectively achieved by having a servlet filter conditionally pipe the produced content to a GZip-compressed file. GZip is supported by the HTTP protocol and almost all modern browsers (hence the servlet filter conditionally compresses the content).</p>
<p>GZip compression usually results in a 6:1 compression ratio, although this depends on how much content is being sent and what the content is.</p>
<h3>Setting up the Servlet Filter in ColdFusion</h3>
<p>Using the ColdBeans servlet filter found at the following URL:</p>
<p><a href="http://www.servletsuite.com/servlets/gzipflt.htm" rel="nofollow">http://www.servletsuite.com/servlets/gzipflt.htm</a></p>
<ul>
<li>Download the <a href="http://www.servletsuite.com/servlets/gzipflt.jar" rel="nofollow">GZipFilter.jar</a></li>
<li>Save GZipFilter.jar in the WEB-INF/lib folder in the ColdFusion Server wwwroot.</li>
<li>Edit the web.xml file in the WEB-INF folder in the ColdFusion Server wwwroot with the following code:

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;filter&gt;
&lt;filter-name&gt;GzipFilter&lt;/filter-name&gt;
&lt;filter-class&gt;com.cj.gzipflt.GzipFilter&lt;/filter-class&gt;
&lt;/filter&gt;
&lt;filter-mapping&gt;
&lt;filter-name&gt;GzipFilter&lt;/filter-name&gt;
&lt;url-pattern&gt;*.cfm&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;</pre></div></div>

</li>
<li>Restart the ColdFusion Service</li>
</ul>
<p>Now, when you invoke any <code>.cfm</code> page the GzipFilter will check out client&#8217;s browser settings. If the browser does not support gzip, the filter invokes resource normally. If the browser does support gzip, output will be compressed.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/poor-mans-http-compression-with-coldfusion/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

