<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-19056005</id><updated>2012-01-23T10:26:49.123-08:00</updated><category term='cfloop'/><category term='Network'/><category term='flash'/><category term='hibernate'/><category term='WebService'/><category term='java'/><category term='coldfusion'/><category term='list'/><category term='Scorpio'/><category term='CFUnited'/><category term='jvm'/><category term='pdf'/><category term='MAX'/><category term='cfdocument'/><category term='jrun'/><category term='listToArray'/><category term='red-x'/><category term='tips'/><category term='ORM'/><category term='optimization'/><category term='file upload'/><category term='mp3'/><category term='performance'/><category term='image'/><category term='caching'/><category term='file'/><title type='text'>Coldfused?</title><subtitle type='html'>My Views on ColdFusion, Java and related technologies</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>76</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-19056005.post-7565403646179081741</id><published>2009-09-15T02:34:00.001-07:00</published><updated>2009-09-15T02:34:34.616-07:00</updated><title type='text'>ColdFusion ORM : Using DB Views instead of Table</title><content type='html'>Posted at &lt;a title="http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-using-db-views-instead-of-table/" href="http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-using-db-views-instead-of-table/"&gt;http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-using-db-views-instead-of-table/&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-7565403646179081741?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/7565403646179081741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=7565403646179081741' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/7565403646179081741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/7565403646179081741'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/09/coldfusion-orm-using-db-views-instead.html' title='ColdFusion ORM : Using DB Views instead of Table'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8960642937221205353</id><published>2009-09-14T01:59:00.001-07:00</published><updated>2009-09-14T01:59:26.159-07:00</updated><title type='text'>ColdFusion ORM : What is "N+1 Select problem"</title><content type='html'>&lt;p&gt;Posted at &lt;a title="http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-what-is-n1-select-problem/" href="http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-what-is-n1-select-problem/"&gt;http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-what-is-n1-select-problem/&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8960642937221205353?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8960642937221205353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8960642937221205353' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8960642937221205353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8960642937221205353'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/09/coldfusion-orm-what-is-select-problem.html' title='ColdFusion ORM : What is &amp;quot;N+1 Select problem&amp;quot;'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8753994879015197353</id><published>2009-09-11T06:36:00.001-07:00</published><updated>2009-09-11T06:36:42.787-07:00</updated><title type='text'>ColdFusion ORM : Performance tuning - Lazy loading</title><content type='html'>&lt;p&gt;Another post in this series posted at &lt;a title="http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-performance-tuning-lazy-loading/" href="http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-performance-tuning-lazy-loading/"&gt;http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-performance-tuning-lazy-loading/&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8753994879015197353?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8753994879015197353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8753994879015197353' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8753994879015197353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8753994879015197353'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/09/coldfusion-orm-performance-tuning-lazy.html' title='ColdFusion ORM : Performance tuning - Lazy loading'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5588805434032753327</id><published>2009-09-10T04:39:00.001-07:00</published><updated>2009-09-10T04:39:54.724-07:00</updated><title type='text'>ColdFusion ORM : Performance tuning – Fetching Strategy</title><content type='html'>&lt;p&gt;Posted at &lt;a title="http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-performance-tuning-fetching-strategy/" href="http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-performance-tuning-fetching-strategy/"&gt;http://www.rupeshk.org/blog/index.php/2009/09/coldfusion-orm-performance-tuning-fetching-strategy/&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5588805434032753327?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5588805434032753327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5588805434032753327' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5588805434032753327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5588805434032753327'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/09/coldfusion-orm-performance-tuning.html' title='ColdFusion ORM : Performance tuning – Fetching Strategy'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-6105802514551775179</id><published>2009-07-31T07:08:00.001-07:00</published><updated>2009-07-31T07:08:33.028-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='ORM'/><title type='text'>ColdFusion ORM : Troubleshooting - 'Lazy' does not work</title><content type='html'>&lt;p&gt;Few days back &lt;a href="http://www.manjukiran.net"&gt;Manju&lt;/a&gt; logged a bug in CF-ORM saying 'lazy' does not work for many-to-one relation and that too on non-Windows machine. At first, I simply rejected the bug because a) ORM can not have anything to do with OS and therefore, if it works on Windows, it works on all the plaform and b) I know it works :-). But he did not agree and I had to take a look at that machine. And apparently he was right - lazy was not working ! The related entity was in-fact getting loaded immediately. (Question for you - how will you know that lazy is working or not?)&lt;/p&gt;  &lt;p&gt;Even after seeing this, I did not believe it and asked him to replicate this on another system and he successfully showed that to me on one another system. And he agreed that it works fine on most of the configurations. The problem exists only on a few of the systems.&lt;/p&gt;  &lt;p&gt;This got me thinking - Why would a relation get loaded immediately even after it is marked lazy? The only answer would be - if some one is accessing that lazy field and calling some method on it. I checked his code which was loading the entities to see if there could be any case, where the field would get loaded and unfortunately there was none.&lt;/p&gt;  &lt;p&gt;And then suddenly it hit me - what if &amp;quot;memory tracking&amp;quot; is swithched on? That would access each of the field of each object recursively to compute the size of an object and that can definitely cause this. I immediately checked the server monitor and the &amp;quot;memory tracking&amp;quot; was right there staring at me in &amp;quot;red&amp;quot;! It was indeed enabled. I asked Manju to check the other system as well (where lazy was not working) and the memory tracking was enabled there as well.&lt;/p&gt;  &lt;p&gt;So the lesson - &lt;strong&gt;If the 'memory tracking' is enabled on the server, the relationship will no longer remain lazy&lt;/strong&gt;. And btw, you should enable &amp;quot;Memory tracking&amp;quot; on the server only if you need to track the memory for some troubleshooting. Memory tracking is really really expensive in terms of performance.&lt;/p&gt;  &lt;p&gt;Another reason why it might not work for you could be - if you are sending the object to flex. Currently, during serialization, the related objects also get sent irrespective of the lazy attribute set on the relationship. We are still working on it and hopefully by the time we release, this will be fixed.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-6105802514551775179?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/6105802514551775179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=6105802514551775179' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6105802514551775179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6105802514551775179'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/coldfusion-orm-troubleshooting-does-not.html' title='ColdFusion ORM : Troubleshooting - &amp;#39;Lazy&amp;#39; does not work'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8725154321599326452</id><published>2009-07-27T07:52:00.001-07:00</published><updated>2009-07-27T07:59:18.144-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='ORM'/><title type='text'>ColdFusion ORM : How to log SQL</title><content type='html'>&lt;p&gt;When you use ORM for developing an application, SQLs are generated and executed by the underlying ORM engine (i.e Hibernate for ColdFusion ORM). However, for both troubleshooting and performance optimization, it is crucial to monitor what queries are getting generated. It can help you find out if there is any error in mapping that you have provided as well as it can help you decide various tuning strategies. &lt;/p&gt; &lt;p&gt;ColdFusion can log the SQLs generated by ORM either onto the console or a file. At the same time it leaves enough hook for you to log it anywhere you want.&lt;/p&gt; &lt;p&gt;ColdFusion ORM provides two ways to log the SQLs.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Using application setting to log to console : This is a quick and simple way to log the sql to console. This is enabled by setting "logsql" in ormsettings. &lt;pre lang="cfm" escaped="true"&gt;   &amp;lt;cfset this.ormsettings.logsql="true"&amp;gt;&lt;/pre&gt;This setting is self sufficient and it will log all the sqls executed by hibernate to the console (or a file where the server output goes). However this is not a very flexible option. The sqls are always written to the console and it will be combined with any other output that goes to console. Also this option will not show the DDL queries used for creating or updating tables. It only logs the SQL for the entity operations. &lt;br /&gt;&lt;li&gt;Using log4J.properties: Hibernate uses &lt;a href="http://logging.apache.org/log4j/"&gt;log4j&lt;/a&gt; for its logging and you can completely control its logging (including SQL) by modifying the log4j.properties. log4j.properties is present under &amp;lt;cf_home&amp;gt;/lib directory. Please note that you don't need to do any application specific setting for this. &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;I will go in details about using log4j.properties for SQL logging. Here is a snippet from log4j.properties file that is shipped with ColdFusion.&lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;###--------------- Hibernate Log Settings ------ &lt;br /&gt;### Set Hibernate log &lt;br /&gt;log4j.logger.org.hibernate=ERROR, HIBERNATECONSOLE &lt;br /&gt; &lt;br /&gt;### log just the SQL &lt;br /&gt;#log4j.logger.org.hibernate.SQL=DEBUG, HIBERNATECONSOLE &lt;br /&gt;#log4j.additivity.org.hibernate.SQL=false &lt;br /&gt;### Also log the parameter binding to the prepared statements. &lt;br /&gt;#log4j.logger.org.hibernate.type=DEBUG &lt;br /&gt;### log schema export/update ### &lt;br /&gt;log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG, HIBERNATECONSOLE &lt;br /&gt;### log cache activity ### &lt;br /&gt;log4j.logger.org.hibernate.cache=ERROR, HIBERNATECONSOLE &lt;br /&gt;&lt;br /&gt;# HibernateConsole is set to be a ColsoleAppender for Hibernate message  using a PatternLayout. &lt;br /&gt;log4j.appender.HIBERNATECONSOLE=org.apache.log4j.ConsoleAppender &lt;br /&gt;log4j.appender.HIBERNATECONSOLE.layout=org.apache.log4j.PatternLayout &lt;br /&gt;log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss} [%t] HIBERNATE %-5p - %m%n%n &lt;br /&gt;#--------------------------------------------- &lt;/pre&gt;&lt;/div&gt;&lt;p&gt;First we will see the relevant settings for SQL logging:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;log4j.logger.org.hibernate.SQL : Defines whether the SQL executed for entity operations will be logged and where it will be logged. The second value for this i.e 'HIBERNATECONSOLE' is a appender that controls &lt;strong&gt;where&lt;/strong&gt; the SQLs will be logged. In the above example HIBERNATECONSOLE is a 'console' appender which means it will log the sql to console. &lt;br /&gt;&lt;li&gt;log4j.logger.org.hibernate.type : Defines whether parameter values used for parametrized query will be logged. &lt;br /&gt;&lt;li&gt;log4j.logger.org.hibernate.tool.hbm2ddl : Defines whether DDL sql statements will be logged. &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;To enable the SQL logging for console, we just need to uncomment the settings mentioned above. Here is how the hibernate log settings in log4j.properties file would look like&lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;###--------------- Hibernate Log Settings ------ &lt;br /&gt;### Set Hibernate log &lt;br /&gt;log4j.logger.org.hibernate=ERROR, HIBERNATECONSOLE &lt;br /&gt; &lt;br /&gt;### log just the SQL &lt;br /&gt;log4j.logger.org.hibernate.SQL=DEBUG, HIBERNATECONSOLE &lt;br /&gt;log4j.additivity.org.hibernate.SQL=false &lt;br /&gt;### Also log the parameter binding to the prepared statements. &lt;br /&gt;#log4j.logger.org.hibernate.type=DEBUG &lt;br /&gt;### log schema export/update ### &lt;br /&gt;log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG, HIBERNATECONSOLE &lt;br /&gt;### log cache activity ### &lt;br /&gt;log4j.logger.org.hibernate.cache=ERROR, HIBERNATECONSOLE &lt;br /&gt;&lt;br /&gt;# HibernateConsole is set to be a ColsoleAppender for Hibernate message  using a PatternLayout. &lt;br /&gt;log4j.appender.HIBERNATECONSOLE=org.apache.log4j.ConsoleAppender &lt;br /&gt;log4j.appender.HIBERNATECONSOLE.layout=org.apache.log4j.PatternLayout &lt;br /&gt;log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss} [%t] HIBERNATE %-5p - %m%n%n &lt;br /&gt;#--------------------------------------------- &lt;/pre&gt;&lt;/div&gt;&lt;a href="http://www.rupeshk.org/misc/2507/1/log4j.properties"&gt;Here is the complete log4j.properties&lt;/a&gt; for logging SQL for console. Ofcourse after changing this you need to restart the server. If you need to log the parameter values used for queries, you need to uncomment '#log4j.logger.org.hibernate.type=DEBUG' as well. &lt;br /&gt;&lt;p&gt;What if you want to log the SQL to a file and not to console? That is pretty easy. You just need to change the 'Appender' used here (HIBERNATECONSOLE) to point to a 'FileAppender' instead of a ConsoleAppender. Here is how the configuration for HIBERNATECONSOLE should look like after you point it to a File Appender. &lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;log4j.appender.HIBERNATECONSOLE=org.apache.log4j.FileAppender&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.File=../hibernatesql.log&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.Append=true&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.layout=org.apache.log4j.PatternLayout&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss} [%t] HIBERNATE %-5p - %m%n%n&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For standalone ColdFusion installation, the file 'hibernatesql.log' will be created in the &lt;cfhome&gt;/logs directory.You can also specify a full path of the file for property 'log4j.appender.HIBERNATECONSOLE.File' and the log will be written to that.&lt;/p&gt;&lt;p&gt;That was easy. Isn't it? What if you want a rolling log file where you dont want the log file size to grow infinitely. That is fairly easy too. All you need to do is to use an appropriate appender. The appender definition for that will look like&lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;log4j.appender.HIBERNATECONSOLE=org.apache.log4j.RollingFileAppender&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.File=../hibernatesql.log&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.Append=true&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.MaxFileSize=500KB&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.MaxBackupIndex=3&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.layout=org.apache.log4j.PatternLayout&lt;br /&gt;log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss} [%t] HIBERNATE %-5p - %m%n%n&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.rupeshk.org/misc/2507/2/log4j.properties"&gt;Here is the complete log4j.properties&lt;/a&gt; for logging SQL to a file that will be rolled automatically once it reaches 500KB.&lt;/p&gt;&lt;p&gt;Now that you have seen how easy it is to change one 'Appender' to another, you can pretty much log it anywhich way you want. Here are some of the interesting 'Appender's that come with log4j which you can easily use.&lt;/p&gt;&lt;p&gt;&lt;a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html"&gt;DailyRollingFileAppender&lt;/a&gt;, &lt;a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/varia/ExternallyRolledFileAppender.html"&gt;ExternallyRolledFileAppender&lt;/a&gt;, &lt;a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/JMSAppender.html"&gt;JMSAppender&lt;/a&gt;, &lt;a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SMTPAppender.html"&gt;SMTPAppender&lt;/a&gt;, &lt;a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SocketAppender.html"&gt;SocketAppender&lt;/a&gt;, &lt;a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/net/SyslogAppender.html"&gt;SyslogAppender&lt;/a&gt;&lt;/p&gt;&lt;p&gt;See &lt;a href="http://logging.apache.org/log4j/1.2/index.html"&gt;log4J&lt;/a&gt; for more details on log4j settings.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8725154321599326452?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8725154321599326452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8725154321599326452' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8725154321599326452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8725154321599326452'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/coldfusion-orm-how-to-log-sql.html' title='ColdFusion ORM : How to log SQL'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-2221347720105084275</id><published>2009-07-18T00:40:00.001-07:00</published><updated>2009-07-18T00:55:52.385-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='ORM'/><title type='text'>ColdFusion 9 : Implicit/Generated CFC Methods</title><content type='html'>&lt;p&gt;How many times did you write the accessor methods (better known as getters and setters) for the fields of your CFC? And how many times did you feel that it was really a mundane job and wished there was a better way to do this? With ColdFusion 9, we have done just that! You no longer need to write those accessors. ColdFusion will automatically generate the accessor methods for you in the object. All you need to do is to define the properties using cfproperty.&lt;/p&gt; &lt;p&gt;Consider this CFC Person.cfc&lt;/p&gt; &lt;div class="code"&gt;&lt;pre&gt;Component Person{&lt;br /&gt;    property firstname;&lt;br /&gt;    property lastname;&lt;br /&gt;    property age;&lt;br /&gt;    property city;&lt;br /&gt;    property state;&lt;br /&gt;}&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;When an object is created for this CFC, you can directly call the setters and getters for the properties as&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&lt;cfscript&gt;&lt;br /&gt;    person = new Person();&lt;br /&gt;    person.setFirstName(&amp;quot;Brad&amp;quot;);&lt;br /&gt;    person.setLastName(&amp;quot;Pitt&amp;quot;);&lt;br /&gt;    person.setAge(46);&lt;br /&gt;&lt;br /&gt;    writeOutput(&amp;quot;Name : #person.getFirstName()# #person.getLastName()#&amp;quot;);&lt;br /&gt;    writeOutput(&amp;quot;Age : #person.getAge()#&amp;quot;); &lt;br /&gt;&lt;/cfscript&gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;The implicit setter/getter uses the 'variable' scope, which is a private scope for a object, for storing the data. i.e the setter method puts the data in the variable scope and the getter method gets the data from the variable scope.&lt;br&gt; &lt;br /&gt;What if you want to override the setter/getter method? Ofcourse you can do that. You just need to define those methods in your CFC and ColdFusion will call your method instead of calling the implicit one.&lt;br /&gt;&lt;p&gt;Hmm.. What if you dont want ColdFusion to generate getter or setter or both methods for a particular property? You can disable that by adding attribute getter=&amp;quot;false&amp;quot; and setter=&amp;quot;false&amp;quot; on the property.&lt;/p&gt;So if you define a property&lt;br&gt;&lt;br /&gt;&lt;pre lang="java"&gt;property name=&amp;quot;city&amp;quot; getter=&amp;quot;false&amp;quot; setter=&amp;quot;false&amp;quot;;&lt;/pre&gt;&lt;p&gt;ColdFusion will not generate getCity() and setCity() methods for this CFC.&lt;/p&gt;&lt;p&gt;The implicit methods can also do some nice validation if you have given the 'type' for properties. Consider the same Person.cfc with type specified where we have made age as a numeric type. &lt;/p&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;Component Person{&lt;br /&gt;    property string firstname;&lt;br /&gt;    property string lastname;&lt;br /&gt;    property numeric age;&lt;br /&gt;    property string city;&lt;br /&gt;    property string state;&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;ColdFusion will do the datatype validation whenever the setter method is called for any property. So if you call&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&lt;cfscript&gt;&lt;br /&gt;    person = new Person();&lt;br /&gt;    person.setFirstName(&amp;quot;Brad&amp;quot;);&lt;br /&gt;    person.setLastName(&amp;quot;Pitt&amp;quot;);&lt;br /&gt;    person.setAge(&amp;quot;LA&amp;quot;);&lt;br /&gt;&lt;/cfscript&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;It will throw a nice error saying &amp;quot;The value cannot be converted to a numeric&amp;quot;.&lt;p&gt;Whats more interesting is that you can do a whole lot of validation using cfproperty. We have added two more attributes on cfproperty named &lt;strong&gt;'validate'&lt;/strong&gt; and &lt;strong&gt;'validateparams'&lt;/strong&gt;. These attributes allow you do even more advanced validations of the property data when the setter method is called for a property. (This is similar to cfparam or cfform validation).&lt;/p&gt;&lt;p&gt;The possible values for validate attributes are&lt;/p&gt;&lt;ul&gt;&lt;li&gt;string&lt;/li&gt;&lt;li&gt;boolean&lt;/li&gt;&lt;li&gt;integer&lt;/li&gt;&lt;li&gt;numeric&lt;/li&gt;&lt;li&gt;date&lt;/li&gt;&lt;li&gt;time&lt;/li&gt;&lt;li&gt;creditcard: A 13-16 digit number conforming to the mod10 algorithm.&lt;/li&gt;&lt;li&gt;email: A valid e-mail address.&lt;/li&gt;&lt;li&gt;eurodate: A date-time value. Any date part must be in the format dd/mm/yy. The format can use /, -, or . characters as delimiters.&lt;/li&gt;&lt;li&gt;regex: Matches input against pattern specified in &lt;samp&gt;validateparams&lt;/samp&gt;.&lt;/li&gt;&lt;li&gt;ssn: A U.S. social security number.&lt;/li&gt;&lt;li&gt;telephone: A standard U.S. telephone number.&lt;/li&gt;&lt;li&gt;UUID: A Home Universally Unique Identifier, formatted 'XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXXX', where 'X' is a hexadecimal number.&lt;/li&gt;&lt;li&gt;guid: A Universally Unique Identifier of the form &amp;quot;XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&amp;quot; where 'X' is a hexadecimal number&lt;/li&gt;&lt;li&gt;zipcode: U.S., 5- or 9-digit format ZIP codes&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;The 'validateparams' attribute available with &lt;samp&gt;&amp;lt;cfproperty&amp;gt;&lt;/samp&gt; takes the parameters required by the validator specified in the 'validate' attribute. This needs to be specified in the implicit struct notation.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;min: Minimum value if 'validate' is integer/numeric&lt;/li&gt;&lt;li&gt;max: Maximum value if the 'validate' is integer/numeric&lt;/li&gt;&lt;li&gt;minLength: Minimum length of the string if the 'validate' is string&lt;/li&gt;&lt;li&gt;maxLength: Maximum length of the string if the 'validate' is string&lt;/li&gt;&lt;li&gt;pattern: regex expression if the validator specified in 'validate' attribute is regex&lt;/li&gt;&lt;/ul&gt;Consider the Person again where we will add few more properties with some validation&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;Component Person{&lt;br /&gt;    property string firstname;&lt;br /&gt;    property string lastname;&lt;br /&gt;    property numeric age;&lt;br /&gt;    property string city;&lt;br /&gt;    /**&lt;br /&gt;     * @validate string&lt;br /&gt;     * @validateparams {minLength=2, maxLength=2}&lt;br /&gt;     */&lt;br /&gt;    property string state;&lt;br /&gt;    /**&lt;br /&gt;     * @validate zipcode&lt;br /&gt;     */&lt;br /&gt;    property numeric zip;&lt;br /&gt;    /**&lt;br /&gt;     * @validate telephone&lt;br /&gt;     */&lt;br /&gt;    proeprty phone; &lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now when you create an object of Person and call setState(state), before setting the data for state in variable scope, ColdFusion will validate that state value provided is of type 'string' and its length is 2. Similarly setZip() will validate that the input data is a valid zip code and setPhone() will validate that the input data is a valid telephone number.&lt;/p&gt;&lt;p&gt;For String type properties, you can also do regular expression validation allows you to have all sort of validation on a property of string type.&lt;/p&gt;&lt;p&gt;And to top it all, all of these nice goodies are available to you at a much lesser cost than regular UDFs. Yes, you read it right. Implicit methods perform much better than regular UDFs that you write in CFC. To confirm that, lets use this CFC where we will use implicit methods for 'firstName' and write our own accessors for 'lastName'.&lt;/p&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;component &lt;br /&gt;{&lt;br /&gt;    property String firstName;&lt;br /&gt;    lastName = &amp;quot;&amp;quot;;&lt;br /&gt;	&lt;br /&gt;    public void function setLastName(string name)&lt;br /&gt;    {&lt;br /&gt;        lastName = name;&lt;br /&gt;    } &lt;br /&gt;	&lt;br /&gt;    public string function getLastName()&lt;br /&gt;    {&lt;br /&gt;        return lastName;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Both implicit methods and UDFs are doing exactly the same thing i.e settings and getting the data in/from variable scope. Now lets run this comparison test&lt;/p&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;cfscript&gt;&lt;br /&gt;    person = new Person();&lt;br /&gt;    t = getTickCount();&lt;br /&gt;    for(i = 0; i &amp;lt; 100000; i++)&lt;br /&gt;    {&lt;br /&gt;        person.setfirstName(&amp;quot;Brad&amp;quot;);&lt;br /&gt;        fname = person.getFirstName();&lt;br /&gt;    }&lt;br /&gt;    writeOutput(&amp;quot;Total Time in implicit methods &amp;quot; &amp;amp; (getTickCount() - t));&lt;br /&gt;    t = getTickCount();&lt;br /&gt;    for(i = 0; i &amp;lt; 100000; i++)&lt;br /&gt;    {&lt;br /&gt;        person.setLastName(&amp;quot;Pitt&amp;quot;);&lt;br /&gt;        lname = person.getLastName();&lt;br /&gt;    }&lt;br /&gt;    writeOutput(&amp;quot;Total Time in UDF methods &amp;quot; &amp;amp; (getTickCount() - t));&lt;br /&gt;&lt;/cfscript&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Here is the output&lt;br /&gt;&lt;pre&gt;Total Time in implicit methods 63&lt;br /&gt;Total Time in UDF methods 485&lt;/pre&gt;&lt;p&gt;Thats almost &lt;strong&gt;eight&lt;/strong&gt; times faster than regular UDF. Isn't that sweet? You get those &lt;strong&gt;auto-generated&lt;/strong&gt; methods, whole lot of &lt;strong&gt;auto-magical validations&lt;/strong&gt; and to top that, &lt;strong&gt;incredible performance&lt;/strong&gt;. I am sure writing accessors for your CFC fields will become a thing of past now !&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-2221347720105084275?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/2221347720105084275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=2221347720105084275' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/2221347720105084275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/2221347720105084275'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/coldfusion-9-implicitgenerated-cfc.html' title='ColdFusion 9 : Implicit/Generated CFC Methods'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-2811065897426667716</id><published>2009-07-17T21:38:00.001-07:00</published><updated>2009-07-17T21:38:47.262-07:00</updated><title type='text'>A demo for ORM code generator in ColdFusion builder</title><content type='html'>&lt;p&gt;Evelin created this nice demo that shows how to setup this &amp;quot;ORM code generator&amp;quot; extension and how to use it. Check out the &lt;a href="http://blogs.adobe.com/cfbuilder/attachments/CFCGenerator4.htm"&gt;demo here&lt;/a&gt;.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-2811065897426667716?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/2811065897426667716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=2811065897426667716' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/2811065897426667716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/2811065897426667716'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/demo-for-orm-code-generator-in.html' title='A demo for ORM code generator in ColdFusion builder'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3572733259559134300</id><published>2009-07-17T05:20:00.001-07:00</published><updated>2009-07-17T05:20:04.550-07:00</updated><title type='text'>ColdFusion Builder : ORM code generator</title><content type='html'>&lt;p&gt;If you have started using ORM (or you want to start) in ColdFusion 9, there is a nice plugin in ColdFusion builder that can help you quickly generate all the ORM code for you. All you do is select the tables from the RDS view, define the relationships, if there is any, and all the code including the service layer will be generated. Evelin talks about it &lt;a href="http://blogs.adobe.com/cfbuilder/2009/07/orm_cfc_generator_1.html"&gt;here&lt;/a&gt;. Oh btw, if you did not notice, thats the &lt;a href="http://blogs.adobe.com/cfbuilder/"&gt;ColdFusion Builder team blog&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;You can download the &lt;a href="http://blogs.adobe.com/cfbuilder/attachments/Adobe%20CFC%20Generator.zip"&gt;plugin from here&lt;/a&gt; and download the &lt;a href="http://blogs.adobe.com/cfbuilder/attachments/Using%20Adobe%20CFC%20Generator.pdf"&gt;instruction from here&lt;/a&gt;. Have Fun playing with it !!!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3572733259559134300?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3572733259559134300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3572733259559134300' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3572733259559134300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3572733259559134300'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/coldfusion-builder-orm-code-generator.html' title='ColdFusion Builder : ORM code generator'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-9051626811300879976</id><published>2009-07-16T09:32:00.001-07:00</published><updated>2009-07-16T09:32:01.154-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='ORM'/><title type='text'>ColdFusion ORM and CFC Performance</title><content type='html'>&lt;p&gt;Since the day we started thinking about ColdFusion ORM, people have been raising concerns over it because of the CFC performance. We have heard people saying that ORM will be unusable because of poor CFC performance and it is a stupid idea to implement CFC based ORM. And today I heard &lt;a href="http://www.halhelms.com/blog/index.cfm/2009/7/14/ColdFusion-and-OOP--A-Match-Made-in-Heaven-or-a-Long-Road-to-Hell"&gt;Hal Helms and Brian kotek talking about it&lt;/a&gt; where Hal says that he shudders at the thought of hibernate integration in CF because of poor performance.&lt;/p&gt;  &lt;p&gt;It is true that CFC performance is poor as compared to POJO and it will always be. ColdFusion CFC has lot of cost involved because of the dyanmic nature of it and additionally, it has reflection cost involved. I had shared some of the reasons with few of the community members and I thought it will be interesting to share it witha wider audience. Here are the main reasons :&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Unlike java where the class has a fully qualified name and is loaded only once in the classloader, when you create CFC, CF needs to search for the CFC file on the disk, compute the class name for it and then load it. And that happens on each object creation unless you have switched on trusted cache .&lt;/li&gt;    &lt;li&gt;CFC&amp;#160; is compiled at runtime, loaded and constructed using reflection. I am sure you will be aware that reflection is much slower (25 times easily) than direct invocation in java.&lt;/li&gt;    &lt;li&gt;CFC has two different scopes - this and variables scope which is a struct. So every object creation involves two additional struct creation cost.&lt;/li&gt;    &lt;li&gt;CFC creation also involves running the default constructor i.e any code outside cffunction and that happens for each object creation. That involves the complete setup for method invocation i.e setting up localscope, superscope etc (another two structs here), which is also significant&lt;/li&gt;    &lt;li&gt;CFC allows UDFs to be added/removed from the object at runtime and hence methods are added to each object on object creation and that too in both the scopes (adding each UDFs in both the scopes also has significant cost). Thats the reason why object creation becomes costlier as you add methods in the CFC. Higher the number of methods, higher the object creation cost.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;We have done a lot of performance improvements regarding CFC creation and invocation in ColdFusion 9 which I hope you would have noticed. But even then it can not match POJO performance and thats an unrealistic target.&lt;/p&gt;  &lt;p&gt;So given that, lets come to the question - How much does CFC creation performance matters when it comes to ORM. In reality, not much. We have done a number of performance comparison between CFC and POJO with hibernate keeping everything else absolutely same. And all the time, CFC performance was same or better than POJO persistence. It might sound unbelievable and in fact I also could not believe it myself when I saw the performance numbers first. But that is the truth. And here is why it happens - When it comes to persistence, the time taken in DB operation and the persistence layer is much more than the time taken in object creation. And that cost is same for POJO and CFC. So the only difference in cost between CFC and POJO with respect to ORM is object creation cost and cost of populating/fetching the properties data. For instantiating POJO object and for using properties accessors, Hibernate has to use reflection which is always costly and that removes this cost difference of CFC and POJO. And for few of the runs, CFC was able to beat POJO as well and explanation for that is the optimizations that we have done in using accessors for properties.&lt;/p&gt;  &lt;p&gt;I would be curious to know about your experience regarding CF-ORM performance and CFC performance in general. How has your experience been so far regarding CF-ORM peformance?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-9051626811300879976?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/9051626811300879976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=9051626811300879976' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/9051626811300879976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/9051626811300879976'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/coldfusion-orm-and-cfc-performance.html' title='ColdFusion ORM and CFC Performance'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3406812031546800826</id><published>2009-07-16T06:49:00.001-07:00</published><updated>2009-07-16T07:11:52.282-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='ORM'/><title type='text'>ColdFusion ORM : The basics</title><content type='html'>&lt;p&gt;Before starting on the advanced topics, I thought it will be better to build some ground and hence I decided to do a post on the ORM basics. In this post, we will build a simple example to get a taste of ColdFusion ORM (CF-ORM) and during that we will also understand some of the basic concepts. &lt;/p&gt;  &lt;p&gt;ORM is &lt;strong&gt;object&lt;/strong&gt; relational mapping and in ColdFusion, objects are created using CFC. CFCs that needs to be persisted are called persistent CFC and that is marked by setting 'persistent' attribute to true on the component. We also need to define what persistent fields will be there in a persistent CFC and that is defined using 'cfproperty'. A field/property is marked persistent by setting persistent attribute to true on the cfproperty. By default, if the CFC is persistent, all its properties are considered as persistent unless you mark a property non-persistent. So typically 'persistent' attribute on the property is used only when you need to make that property non-persistent. &lt;/p&gt;  &lt;p&gt;Each persistent CFC in ColdFusion application maps to a table in the database and each property in the persistent CFC maps to a column in the table (not exactly true but we will come to that later.. For the time being lets keep it that way). We will use the cfartgallery datasource for this example which has Artists and Art tables. &lt;/p&gt;  &lt;p&gt;The first thing you need to do is - enable ORM for the application and define a datasource to be used (What is an ORM without a datasource?). ColdFusion ORM uses Application.cfc to define all the ORM specific settings. (If you haven't started using Application.cfc for your application, its time to start using it!) &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Application.cfc&lt;/strong&gt; &lt;/p&gt;  &lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;Component {&lt;br /&gt;   this.name="ArtGallery";&lt;br /&gt;   this.ormenabled="true";&lt;br /&gt;   this.datasource="cfartgallery";&lt;br /&gt;} &lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Note that the datasource setting defined here makes it the default datasource of your application which can be used by tags like cfquery, cfinsert, cfupdate, cfdbinfo. The same default datasource will be used by ORM as well.&lt;br&gt;&lt;br /&gt;There are a whole bunch of &lt;a href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html"&gt;ORM related configuration&lt;/a&gt; that you can do in application.cfc which you can refer &lt;a href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSED380324-6CBE-47cb-9E5E-26B66ACA9E81.html"&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br /&gt;Now that the application is configured, let us build the object and define the persistence information on it. To start with, we will first define the Artist.cfc &lt;br /&gt;&lt;pre&gt;&lt;strong&gt;Artists.cfc&lt;/strong&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;/**&lt;br /&gt;* @persistent&lt;br /&gt;*/&lt;br /&gt;Component {&lt;br /&gt;   property name="artistid" generator="increment";&lt;br /&gt;   property firstname;&lt;br /&gt;   property lastname;  &lt;br /&gt;   property address;&lt;br /&gt;   property city;&lt;br /&gt;   property state;&lt;br /&gt;   property postalcode;&lt;br /&gt;   property email;&lt;br /&gt;   property phone;        &lt;br /&gt;   property fax;&lt;br /&gt;   property thepassword;&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;This is the most simplistic definition of the component where we have defined only the component and its properties names. Since the table for this CFC already exists in the database, we have not added any table specific information in this and we will let ORM infer all the information from the database. The only additional setting that we have added here is the 'generator' attribute which is used to auto-generate the primary key.&lt;br&gt;&lt;br /&gt;After the components are defined, the first request to this application (i.e a page in this application) will make CF-ORM do all the setup necessary (basically generation of hibernate configuration, mapping files, building the session factory etc). Once the setup is done, you are all set to work with the entities.&lt;br&gt;&lt;br /&gt;We will first list all the artists and here is what you need to do for that&lt;br&gt;&lt;br /&gt;&lt;strong&gt;listAll.cfm&lt;/strong&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;  artists = EntityLoad("Artists");&lt;br /&gt;  writedump(artists);&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;To load a particular Artists with its ID, here is what you do&lt;br /&gt;&lt;strong&gt;list.cfm&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;  artist = EntityLoadByPK("Artists", 1);&lt;br /&gt;  writedump(artist);&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;There are several flavors of EntityLoad functions details of which can be read &lt;a href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS02BE9BC5-8206-434b-8486-95CD09CDB985.html#WSf01dbd23413dda0e54af3c7912012f78097-7ff8"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Let us now see how to perform insert and update on it.&lt;br&gt;&lt;br /&gt;&lt;strong&gt;save.cfm&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;  // Insert a new artist&lt;br /&gt;  artist = new Artists();&lt;br /&gt;  artist.setfirstname("Leonardo");&lt;br /&gt;  artist.setlastname("Da vinci");&lt;br /&gt;  artist.setcity("Paris");&lt;br /&gt;  EntitySave(artist);&lt;br /&gt;  writeOutput(artist.getartistid());// Update an artist&lt;br /&gt;  artist = EntityLoadByPK("Artists", 2);&lt;br /&gt;  artist.setcity("NewYork"); // artist is automatically updated.&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;As we see in the above example, EntitySave is used to insert/update an object in the table. There are some important things to note here&lt;br /&gt;&lt;ul&gt;&lt;li&gt;EntitySave is an intelligent function which automatically finds if a new row needs to be inserted for the given object or whether an existing row needs to be updated. &lt;/li&gt;&lt;li&gt;We called EntitySave for the insert here but not for update but even then artist '2' gets updated. So how did that happen? Actually what happens here is when you load an artist object, it becomes associated with the hibernate session which keeps track of any changes in the object and automatically saves it when the session is flushed. We will talk about more about hibernate session in a later post. For the time being lets just say that Hibernate Session is a short-lived object that represents a conversation between the application and the persistence layer and also acts as the first level of cache. &lt;/li&gt;&lt;li&gt;We did not write any setter or getter method for artist's properties in Artists.cfc but we are calling them here. That works because ColdFusion 9 automatically generates accessor methods for any property written in a CFC. More details on generated methods in a later post. &lt;/li&gt;&lt;li&gt;At line no 6, we called entitySave, but if you check the database, the row is not inserted yet. So when does that happen? Hibernate batches up all the operations till the end of the request or to be exact till hibernate session is flushed. ColdFusion ORM starts up a session when the first ORM method is called in the request and is automatically flushed when the request ends. The batching is done for performance reason so that hibernate executes the sql with the final state of the objects. It will be a huge performance bottleneck if ORM keeps executing sql for each changes in the object. &lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;To delete an Artist, you need to call EntityDelete() passing the object to be deleted. &lt;br&gt;&lt;br /&gt;&lt;strong&gt;delete.cfm&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;cfscript&gt;&lt;br /&gt;   artist = EntityLoadByPK("Artists", 15, true);&lt;br /&gt;   EntityDelete(artist);&lt;br /&gt;&lt;/cfscript&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3&gt;Relationship&lt;/h3&gt;&lt;br /&gt;So far we have seen how to perform CRUD for a single entity. But in any application, there will be entities which are associated and ORM must load the associated object as well when loading a particular entity. For our example, an Art will have an Artist and when loading the art object, it should also load the associated artist. So lets build the model first after which we will see how to work with the association.&lt;br&gt;&lt;br /&gt;In cfartgallery, the table Artists has a one-to-many relationship with Art table, which are joined using the foreign key column ARTISTSID. This means that each artist has created multiple arts and each art is created by one artist. To represent this in the object model, each ARTIST object would contain an array of ART objects. Each ART object will also contain a reference to its ARTIST object thereby forming a bidirectional relation.&lt;br&gt;&lt;br /&gt;To achieve this, we will need to add an extra property 'arts' to 'Artists' that contains an array of ART objects for that Artist. The modified Artists.cfc would look like&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;/**&lt;br /&gt;* @persistent&lt;br /&gt;*/&lt;br /&gt;Component {&lt;br /&gt;   property name="artistid" generator="increment";&lt;br /&gt;   property firstname;&lt;br /&gt;   property lastname;  &lt;br /&gt;   property address;&lt;br /&gt;   property city;&lt;br /&gt;   property state;&lt;br /&gt;   property postalcode;&lt;br /&gt;   property email;&lt;br /&gt;   property phone;        &lt;br /&gt;   property fax;&lt;br /&gt;   property thepassword;&lt;br /&gt;   property name="arts" fieldtype="one-to-many" fkcolumn="artistid" cfc="Art" cascade="all" inverse="true";&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Here is the &lt;strong&gt;Art.cfc&lt;/strong&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;/**&lt;br /&gt;* @persistent&lt;br /&gt;*/&lt;br /&gt;Component {&lt;br /&gt;   property name="artid" generator="increment";&lt;br /&gt;   property artname;&lt;br /&gt;   property price;&lt;br /&gt;   property largeimage;&lt;br /&gt;   property mediaid;&lt;br /&gt;   property issold;&lt;br /&gt;   property name="artist" fieldtype="many-to-one" fkcolumn="artistid" cfc="Artists" ;&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Notice the artist property above which is of many-to-one type. Also notice that both the property use the same value for fkcolumn attribute i.e 'artistid' of Art table that references artistID pk of Artist table.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Since we have added a new persistent CFC (Art.cfc) after the application was loaded, we need to re-initialize the ORM for this application so that mappings for Art.cfc also gets generated. This can be done by calling ORMReload() method. There are some nice ways to do this but for the time being lets keep it simple by putting this in a separate page which we will call to reload ORM.&lt;br&gt;&lt;br /&gt;&lt;strong&gt;initializeORM.cfm&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;cfset ormReload()&amp;gt;&lt;/pre&gt;&lt;br /&gt;If you load and dump Artist (using listAll.cfm), you should also see the associated art objects for artists.&lt;br&gt;&lt;br /&gt;Now let us create a new Art and associate it with an existing Artist.&lt;br /&gt;&lt;b&gt;artCreate.cfm&lt;/b&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;   artist = EntityLoad("artists", 1 ,"true");&lt;br /&gt;   art = new Art();&lt;br /&gt;   art.setartname("landscape");&lt;br /&gt;   art.setPrice(1500);&lt;br /&gt;   art.setissold(false);&lt;br /&gt;   art.setartist(artist);&lt;br /&gt;   artist.addArts(art);&lt;br /&gt;   EntitySave(art);&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;If you notice line 7-8 above, we associate artist to art by calling art.setArtist(artist) as well as art to artist by calling artist.addArts(art). Hibernate needs us to do this in order to set up the bidirectional relation properly. Since it is a bidirectional relation, you must also decide which side will set the relation in the database. i.e which side of the relation will set the fkcolumn in the table. This is controlled by the "inverse" attribute of proeprty, which if set to true, tells hibernate that this is a inverse of the other relation and this side of relation should be ignored for persistance. If you don't set inverse to true, Hibernate will unnecessarily fire two sqls for the same association. &lt;br&gt;&lt;br /&gt;So there you have it. We have seen how you can use ORM to perform the basic CRUD operations on entities. For more details, you can refer to the &lt;a href="http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSD628ADC4-A5F7-4079-99E0-FD725BE9B4BD.html"&gt;ORM doc&lt;/a&gt; and &lt;a href="http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/"&gt;Hibernate docs&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3406812031546800826?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3406812031546800826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3406812031546800826' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3406812031546800826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3406812031546800826'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/coldfusion-orm-basics.html' title='ColdFusion ORM : The basics'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5776204591840048066</id><published>2009-07-13T22:51:00.001-07:00</published><updated>2009-07-13T22:51:38.129-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='ORM'/><title type='text'>ColdFusion ORM - An Evolution in building datacentric application</title><content type='html'>&lt;p&gt;As we all know, ColdFusion was born as DBML - a script that was very similar to HTML but had certain tags that could perform database operation and it revolutionized the way web applications were built. Tags like cfquery, cfinsert, cfupdate made it very easy to perform database operations while building web application. Even after 14 years of CFML, (which we incidently completed day before yesterday), cfquery is *the* most popular and the most commonly used tag. However there are few downsides to it&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Database vendor dependency - The queries that are written are DB specific. If you ever need to switch the database or if you need to make the application database agnostic, it becomes too much of pain. You will end up changing the entire application code or lot of conditional code to handle queries for different databases. &lt;/li&gt;    &lt;li&gt;Very tight coupling with the database - The queries have very tight coupling with the database. This means that if there is any change in the table name or column name, you will end up with changes all over your application code. &lt;/li&gt;    &lt;li&gt;Repititive and hence low on productivity - For any CRUD (Create, read, update and delete) operation, you need to write queries which are more or less same for all the tables. You must have felt that you are repeating the same code everywhere in the application. There is too much of repititiveness which reduces productivity. &lt;/li&gt;    &lt;li&gt;Error prone - How many times did you write insert/update queries and then you had to struggle to debug because the order of column and its values were different? And how many times did you get frustrated because there was a datatype mismatch between the value you had specified and the one expected? How many times did you write a query that was prone to sql injection and you were reminded to use query param? I am sure all of this has happened to all of us and its completely natural given the way queries are written. They are error prone. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;ColdFusion 9 introduces a new way to build datacentric application using ORM, that handles all the downsides we saw above. It is not a replacement to cfquery/cfinsert/cfupdate tags but its a different approach altogether. It allows you to build your application using objects where you focus on the business logic and all the grunt work of persistence is taken care automatically (In simple words you dont write SQL queries generally).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Object-relational_mapping"&gt;ORM (Object relational mapping)&lt;/a&gt; is a well known strategy/technique to map relational data to the object model. In an object model, business objects are not aware of the database structure. Objects have properties and references to other objects whereas Databases consist of tables with columns that are related to other tables using foreign key. ORM provides a bridge between the relational database and the object model allowing you to access and update data entirely using the object model of an application.&lt;/p&gt;  &lt;p&gt;ORM is not new to ColdFusion either - &lt;a href="http://www.transfer-orm.com/"&gt;Transfer&lt;/a&gt; and &lt;a href="http://trac.reactorframework.com/"&gt;Reactor&lt;/a&gt; being the most popular ones. ColdFusion ORM (or CF-ORM) is much more extensive and sophisticated ORM solution than these ORMs. ColdFusion ORM is built on top of &lt;a href="http://www.hibernate.org/"&gt;Hibernate&lt;/a&gt; - the best java ORM engine out there, which is quite powerful and extensive. ColdFusion ORM makes it very easy to use persistence with objects and at the same time allows you to leverage the full power of Hibernate.&lt;/p&gt;  &lt;p&gt;ColdFusion ORM provides features such as&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Defining the persistence mapping and managing the object's persistence using very simple methods. &lt;/li&gt;    &lt;li&gt;Database vendor independence &lt;/li&gt;    &lt;li&gt;Loose coupling between database and application - The application becomes very adaptive to changes as the configuration is central and changes will be required only there. &lt;/li&gt;    &lt;li&gt;Auto-generation of schema - ORM lets you auto-generate the schema for your application. So you never need to bother about keeping your object model and the database schema in sync. It can automatically happen. &lt;/li&gt;    &lt;li&gt;Productivity and manageability - Since ORM takes care of all persistence grunt work, you focus on your application logic and thus your application becomes much more cleaner and manageable. It also makes you lot more productive as application can be built much more faster. &lt;/li&gt;    &lt;li&gt;Concurrency - ORM inherently takes care of concurrency control. So you dont need to worry much about how things would work when multiple database operations happen in parallel web requests. &lt;/li&gt;    &lt;li&gt;Performance - ORM provides lot of performance optimizations that can make your application run faster. The optimizations include two levels of caching (including pluggable distributed cache), lazy loading, various settings to tune the sql queries generated by ORM. &lt;/li&gt;    &lt;li&gt;Secure - Since queries will be executed by ORM, issues like SQL injection no longer exist and thus your application becomes secure. &lt;/li&gt;    &lt;li&gt;Inbuilt pagination &lt;/li&gt;    &lt;li&gt;SQL like query (HQL) for a finer control of the data to be loaded. &lt;/li&gt;    &lt;li&gt;... &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In this series of posts, I will be talking lot more about ORM which I hope you would like. In case you have not downloaded ColdFusion 9 beta, go &lt;a href="http://labs.adobe.com/technologies/coldfusion9/"&gt;download it&lt;/a&gt; and start playing with it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5776204591840048066?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5776204591840048066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5776204591840048066' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5776204591840048066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5776204591840048066'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/coldfusion-orm-evolution-in-building.html' title='ColdFusion ORM - An Evolution in building datacentric application'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-1497610794742844751</id><published>2009-07-13T22:44:00.001-07:00</published><updated>2009-07-13T22:44:38.395-07:00</updated><title type='text'>Moving my blog to a new address</title><content type='html'>&lt;p&gt;With the release of ColdFusion 9 beta, I am also moving my blog from blogger to a &lt;a href="http://www.rupeshk.org/"&gt;new address&lt;/a&gt; (&lt;a href="http://www.rupeshk.org"&gt;http://www.rupeshk.org&lt;/a&gt;). I have moved all the content including comments from blogger to the new site. The new blog is still in beta as I still need to do lot of cleanup.&lt;/p&gt;  &lt;p&gt;I will keep posting the entries to both the blogs for some time till I feel that the traffic has moved to the new blog. So please put all your comments on the new blog so that its all at one place :-)&lt;/p&gt;  &lt;p&gt;If you are subscribing to my feed or if you have linked to this blog, you can change that to use the &lt;a href="http://www.rupeshk.org/blog/index.php/feed/"&gt;new feed&lt;/a&gt;. See you over at &lt;a href="http://www.rupeshk.org"&gt;http://www.rupeshk.org&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-1497610794742844751?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/1497610794742844751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=1497610794742844751' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/1497610794742844751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/1497610794742844751'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/moving-my-blog-to-new-address.html' title='Moving my blog to a new address'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3259642672756380005</id><published>2009-07-12T22:48:00.001-07:00</published><updated>2009-07-12T22:48:02.723-07:00</updated><title type='text'>ColdFusion 9 and ColdFusion builder beta available</title><content type='html'>&lt;p&gt;I am sure by the time you will be reading this, the blogosphere will be buzzing with this news :-). We just (13th July 12:01 AM EST) went live with the beta of ColdFusion 9 and ColdFusion builder. All of us in the team had been working really hard for last one and half years to put in features, that will take RAD to the next level, features that will make your life easy, features that you are going to love. ColdFusion has always been known for &amp;quot;making hard things easy&amp;quot; and I am sure this release will make even harder things easy :-)&lt;/p&gt;  &lt;p&gt;Ben talked about the new features in &lt;a href="http://labs.adobe.com/technologies/coldfusion9/"&gt;ColdFusion 9&lt;/a&gt; and &lt;a href="http://labs.adobe.com/technologies/coldfusionbuilder/"&gt;ColdFusion beta&lt;/a&gt; here :&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_whatsnew.html" href="http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_whatsnew.html"&gt;http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_whatsnew.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.adobe.com/devnet/coldfusion/articles/cfbuilder_whatsnew.html" href="http://www.adobe.com/devnet/coldfusion/articles/cfbuilder_whatsnew.html"&gt;http://www.adobe.com/devnet/coldfusion/articles/cfbuilder_whatsnew.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Here are the links for public beta&lt;/p&gt;  &lt;p&gt;ColdFusion 9 : &lt;a title="Hhttp://labs.adobe.com/technologies/coldfusion9/" href="http://labs.adobe.com/technologies/coldfusion9/"&gt;http://labs.adobe.com/technologies/coldfusion9/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;ColdFusion Builder : &lt;a title="Hhttp://labs.adobe.com/technologies/coldfusionbuilder/" href="http://labs.adobe.com/technologies/coldfusionbuilder/"&gt;http://labs.adobe.com/technologies/coldfusionbuilder/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I also wanted to highlight an excellent devnet article written by Mark Mandel &lt;a href="http://www.adobe.com/devnet/coldfusion/articles/coldfusion9_orm.html"&gt;introducing ColdFusion ORM&lt;/a&gt;. I am sure ColdFusion ORM is going to completely change the way ColdFusion applications are built and is going to make you much more productive. Hey, I am not boasting because its my baby, but I genuinely feel this :-)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3259642672756380005?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3259642672756380005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3259642672756380005' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3259642672756380005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3259642672756380005'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/07/coldfusion-9-and-coldfusion-builder.html' title='ColdFusion 9 and ColdFusion builder beta available'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5511287063252090680</id><published>2009-06-13T06:38:00.001-07:00</published><updated>2009-06-13T06:38:00.185-07:00</updated><title type='text'>Devnet Article on ColdFusion Performance tuning</title><content type='html'>&lt;p&gt;In case you haven't seen it yet, there is a new devnet atricle that was published this week on &amp;quot;&lt;a href="http://www.adobe.com/devnet/coldfusion/articles/coldfusion_performance.html"&gt;Performance tuning for ColdFusion Application&lt;/a&gt;&amp;quot;. Its an excellent article written by Kunal from the ColdFusion team. It gives a great insight into how to go about tuning your JVM, how to tune the VM's Garbage collector settings and how to tune different settings in ColdFusion server. It also gives some tips on best practices for writing ColdFusion application from a performance perspective. Overall an excellent article. &lt;/p&gt;  &lt;p&gt;However, there is one mistake in the fourth page where it suggests to use File functions instead of File tag which I would like to correct. Actually it should have suggested to use &lt;a href="http://coldfused.blogspot.com/2007/07/new-file-io-in-coldfusion-8.html"&gt;new File functions that were introduced in ColdFusion 8&lt;/a&gt; instead of older File functions or cfile tag.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5511287063252090680?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5511287063252090680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5511287063252090680' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5511287063252090680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5511287063252090680'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2009/06/devnet-article-on-coldfusion.html' title='Devnet Article on ColdFusion Performance tuning'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8351374702023458973</id><published>2008-07-01T01:45:00.001-07:00</published><updated>2008-07-01T01:45:49.150-07:00</updated><title type='text'>ColdFusion Livedocs on AIR</title><content type='html'>&lt;p&gt;I was doing a code review for Vinu today (dont ask me which feature it was :-)) and we needed to check the reference doc for a tag. And instead of opening the local doc page, he opened this cool application that had livedocs and it was blazing fast (I know Livedocs sucks ! and yes I work for Adobe ;-)). &lt;/p&gt;  &lt;p&gt;I was like 'whoa!! thats a cool app.. Did you write it? Why dont you release it for public??' And then he told me that some one from the community had written it and its already available for everyone. It has been developed by &lt;a href="http://www.brianflove.com"&gt;Brian Love&lt;/a&gt; and it is available &lt;a href="http://www.brianflove.com/public/CFDocsOnAIR/"&gt;here&lt;/a&gt;. It has very small size application, very lightweight and extremely fast.&lt;/p&gt;  &lt;p&gt;So in case you haven't downloaded it, &lt;a href="http://brianflove.com/air/CFDocs.air"&gt;download it&lt;/a&gt; now!! I am sure you would love it.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8351374702023458973?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8351374702023458973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8351374702023458973' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8351374702023458973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8351374702023458973'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/07/coldfusion-livedocs-on-air.html' title='ColdFusion Livedocs on AIR'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3656109994618168591</id><published>2008-06-30T06:28:00.001-07:00</published><updated>2008-07-01T01:48:29.660-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>New 'EvalAtPrint' attribute in CFDocumentItem</title><content type='html'>&lt;p&gt;A new evalAtPrint attribute has been added to cfdocumentitem tag in ColdFusion 801 which is applicable when the item type is header or footer. The default value of this attribute is false.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; The cfdocumentitem behavior with the default evalAtPrint value is identical to the behavior in ColdFusion MX 7, but differs from the behavior of the ColdFusion 8 release.&lt;/p&gt;  &lt;p&gt;When the evalAtPrint attribute value is false, the default value, ColdFusion evaluates the cfdocumentitem tag body at the same time when it is processing the cfdocument tag. This is the behavior identical to CFMX7. In this case you can use CFDocument variables (TotalPageCount, CurrentPageNumber, TotalSectionpageCount and CurrentSectionpageNumber) only inside cfoutput and not in any expression because the page numbers are not known unless the cfdocument body content is evaluated and layed out.&lt;/p&gt;  &lt;p&gt;In order to use CFDocument variables in expression inside CFDocumentItem tagbody, you should set evalAtPrint to true as shown in the following example.&lt;/p&gt;  &lt;pre&gt;&lt;div class="code"&gt;&amp;lt;cfdocument format="pdf"&amp;gt;&lt;br /&gt;   &amp;lt;cfdocumentitem type="header" evalAtPrint="true"&amp;gt;&lt;br /&gt;       &amp;lt;cfif (CFDocument.currentPageNumber % 2 eq 0)&amp;gt;&lt;br /&gt;           &amp;lt;cfoutput&amp;gt; Page is even&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;       &amp;lt;cfelse&amp;gt;&lt;br /&gt;           &amp;lt;cfoutput&amp;gt; Page is odd&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;       &amp;lt;/cfif&amp;gt;&lt;br /&gt;   &amp;lt;/cfdocumentitem &amp;gt;&lt;br /&gt;   Document body…&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;In this case, ColdFusion evaluates the cfdocumentitem tag body when it prints the header or footer, not when it evaluates the cfdocument tag body. This ensures that the cfdocument tag body is already evaluated and layed out and page number information is available when cfdocumentitem tag is being evaluated&lt;p&gt;A side effect of this is, if a variable is used inside both cfdocument and cfdocumentitem, cfdocumentitem tag will only see the final value of that variable. In the following example, cfdocumentitem will always get 11 as value of ‘I’ and hence all the headers will print ‘Chapter 11’.&lt;/p&gt;&lt;pre&gt;&lt;div class="code"&gt;&lt;br /&gt;&amp;lt;cfdocument format="pdf" &amp;gt;&lt;br /&gt;&amp;lt;cfloop from=1 to=10 index="i"&amp;gt;&lt;br /&gt;   &amp;lt;cfdocumentsection&amp;gt;&lt;br /&gt;   &amp;lt;cfdocumentitem type="header" &amp;gt;&lt;br /&gt;       &amp;lt;cfoutput&amp;gt;Chapter #i#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;   &amp;lt;/cfdocumentitem &amp;gt;&lt;br /&gt;DocumentSection body&lt;br /&gt;   &amp;lt;/cfdocumentsection&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;To handle this, you can now pass the variable into the cfdocumentitem tag as a custom attribute, as shown in the following example:&lt;br /&gt;&lt;pre&gt;&lt;div class="code"&gt;&lt;br /&gt;&amp;lt;cfdocument format="pdf" &amp;gt;&lt;br /&gt;   &lt;strong&gt;&amp;lt;cfloop from=1 to=10 index="i"&amp;gt;&lt;/strong&gt;&lt;br /&gt;       &amp;lt;cfdocumentsection&amp;gt;&lt;br /&gt;           &lt;strong&gt;&amp;lt;cfdocumentitem type="header" evalAtPrint="true" no = #i#&amp;gt;&lt;br /&gt;               &amp;lt;cfoutput&amp;gt;Chapter #attributes.no#&amp;lt;/cfoutput&amp;gt; &lt;/strong&gt;&lt;br /&gt;               &amp;lt;cfif (CFDocument.currentPageNumber % 2 eq 0)&amp;gt;&lt;br /&gt;                   &amp;lt;cfoutput&amp;gt; Page is even&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;               &amp;lt;cfelse&amp;gt;&lt;br /&gt;                   &amp;lt;cfoutput&amp;gt; Page is odd&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;               &amp;lt;/cfif&amp;gt;&lt;br /&gt;           &amp;lt;/cfdocumentitem &amp;gt;&lt;br /&gt;           Document Body.&lt;br /&gt;       &amp;lt;/cfdocumentsection&amp;gt;&lt;br /&gt;   &amp;lt;/cfloop&amp;gt;&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3656109994618168591?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3656109994618168591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3656109994618168591' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3656109994618168591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3656109994618168591'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/06/new-attribute-in-cfdocumentitem.html' title='New &amp;#39;EvalAtPrint&amp;#39; attribute in CFDocumentItem'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3763387526511797881</id><published>2008-06-30T00:26:00.001-07:00</published><updated>2008-06-30T00:26:09.116-07:00</updated><title type='text'>CFUnited Presentation - All about CFThread</title><content type='html'>&lt;p&gt;I did a presentation on &amp;quot;All about CFThread&amp;quot; at CFUnited this year and I think it went fairly well. It was a repeat session - once on friday 21st June and another on Saturday 22nd June and both the sessions had pretty good number of people attending it. Thanks a lot to all those attended. As promised, I have uploaded my &lt;a href="http://rupeshk.org/preso/cfunited08/CFThread_CFUnited.pdf"&gt;presentation&lt;/a&gt; and the &lt;a href="http://rupeshk.org/preso/cfunited08/cfthreaddemo.zip"&gt;sample code&lt;/a&gt; up &lt;a href="http://rupeshk.org/preso/cfunited08/"&gt;here&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Please feel free to ask me questions if you have any.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3763387526511797881?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3763387526511797881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3763387526511797881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3763387526511797881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3763387526511797881'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/06/cfunited-presentation-all-about.html' title='CFUnited Presentation - All about CFThread'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-6690257095673454861</id><published>2008-06-27T06:37:00.001-07:00</published><updated>2008-06-27T06:37:34.535-07:00</updated><title type='text'>Back from hiatus</title><content type='html'>&lt;p&gt;I took a long long break from blogosphere and now that I am rejuvenated after CFUnited, I am back. :-) Thinking about it, it was a really long break - my last post was on Feb 18th which makes it 4 months. So what did I do in those last 4 months? Well lot of things ;-)&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;I GOT MARRIED :-) So thats the biggest thing that happened. I took a one month long vacation to get married, went to Mauritius for my honeymoon and we had a really great time. Here is one of our pics. In case you want to see more of these, you can head over to &lt;a title="http://www.flickr.com/photos/kum_rupesh" href="http://www.flickr.com/photos/kum_rupesh"&gt;Flickr&lt;/a&gt;. :D &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160; &lt;img style="margin: 0px 0px 0px 200px" src="http://lh5.ggpht.com/rupeshk/SAZJOhUMTKI/AAAAAAAAAHw/xARoHUVZiLk/IMG_0920.jpg?imgmax=400" /&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;There was a more than one month long Cricket series called &amp;quot;Indian Premier League&amp;quot; and I watched each and every match ;-) &lt;/li&gt;    &lt;li&gt;All of us in the ColdFusion team were quite busy (and still are) in research, planning and implentation for the Centaur. In other words, I was working for you guys. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Now that I am back, you should see some regular posts from me. The next one goes in a while.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-6690257095673454861?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/6690257095673454861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=6690257095673454861' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6690257095673454861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6690257095673454861'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/06/back-from-hiatus.html' title='Back from hiatus'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/rupeshk/SAZJOhUMTKI/AAAAAAAAAHw/xARoHUVZiLk/s72-c/IMG_0920.jpg?imgmax=400' height='72' width='72'/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-9029969958486776685</id><published>2008-02-18T05:33:00.001-08:00</published><updated>2008-02-18T05:35:17.394-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='mp3'/><title type='text'>Reading MP3 meta-data from ColdFusion</title><content type='html'>&lt;p&gt;On friday I posted about how to &lt;a href="http://coldfused.blogspot.com/2008/02/reading-flash-swf-metadata-from.html"&gt;read the meta-data for Swf (flash) file from ColdFusion&lt;/a&gt; and on the same note, I think it will be cool to read the meta-data for MP3 file as well. &lt;a href="http://www.dv.co.yu/mpgscript/mpeghdr.htm"&gt;Here&lt;/a&gt; is the specification for MP3 header and it is fairly straight forward to read the header using the spec.&lt;/p&gt;  &lt;p&gt;ColdFusion 8 knows how to read MP3 file and it can provide a set of meta-data for it. Though this functionality is not exposed via any tag or function, you can still use it. The meta-data it provides are&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Bit Rate : in kbps &lt;/li&gt;    &lt;li&gt;Frequency : in Hz&lt;/li&gt;    &lt;li&gt;Play duration : in second &lt;/li&gt;    &lt;li&gt;Version : integer     &lt;ul&gt;       &lt;ul&gt;         &lt;li&gt;0 - MPEG version 2.5 &lt;/li&gt;          &lt;li&gt;1 - MPEG version 2 &lt;/li&gt;          &lt;li&gt;3 - MPEG version 1 &lt;/li&gt;       &lt;/ul&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Copy Right : true/false &lt;/li&gt;    &lt;li&gt;Channel mode : integer     &lt;ul&gt;       &lt;ul&gt;         &lt;li&gt;0 - Stereo &lt;/li&gt;          &lt;li&gt;1 - Joint Stereo &lt;/li&gt;          &lt;li&gt;2 - Dual Channel &lt;/li&gt;          &lt;li&gt;3 - Mono or Single Channel &lt;/li&gt;       &lt;/ul&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here is an example code.&lt;/p&gt;  &lt;pre&gt;&lt;div class="code"&gt;&amp;lt;cfset mp3File = createObject("java", "coldfusion.util.MP3File").init("C:\music.mp3")&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;mp3File.getBitRate() : #mp3File.getBitRate()# kbps&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;mp3File.getFrequency() : #mp3File.getFrequency()# Hz&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;mp3File.getVersion() : #mp3File.getVersion()#&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;mp3File.getDuration() : #mp3File.getDuration()# Sec&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;mp3File.isCopyRighted() : #mp3File.isCopyRighted()#&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;mp3File.getChannelMode() : #mp3File.getChannelMode()#&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;p&gt;Though you can use the above mentioned class (coldfusion.util.MP3File) without any problem, you must keep it in mind that it is unsupported and *might* change in future. Just a disclaimer !!! :-) &lt;/p&gt;&lt;p&gt;This class does not get you the ID3V1 or &lt;a href="http://www.id3.org/id3v2.3.0"&gt;ID3V2&lt;/a&gt; meta-data, but it should be easy for you to do it. For ID3V1, all you need to do is to read the last 128 bytes of the mp3 file and you have all the information required. Reading ID3V2 tag is little more involved and there are a number of open source java libraries available (common one being &lt;a href="http://javamusictag.sourceforge.net/"&gt;jidlib&lt;/a&gt; and &lt;a href="http://www.jthink.net/jaudiotagger/index.jsp"&gt;jaudiotagger&lt;/a&gt;) which can be used.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-9029969958486776685?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/9029969958486776685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=9029969958486776685' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/9029969958486776685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/9029969958486776685'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/02/reading-mp3-meta-data-from-coldfusion.html' title='Reading MP3 meta-data from ColdFusion'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-4199988373427570984</id><published>2008-02-15T09:34:00.001-08:00</published><updated>2008-02-15T09:37:54.906-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='flash'/><title type='text'>Reading Flash (Swf) metadata from ColdFusion</title><content type='html'>&lt;p&gt;Wouldn't it be cool if you could read the meta-data of Swf file in ColdFusion? The most common use case I can think of is to find the dimension of swf movie so that you can set the dimension for the same in object tag while you are embedding the flash movie in your page. And the good news is that you can do that currently in ColdFusion with just 2-3 lines of code!! All you need to do is to create a TagDecoder and decoder the header with it. Here is the complete code.&lt;/p&gt;  &lt;pre&gt;&lt;div class="code"&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;  fis = createObject("java", "java.io.FileInputStream").init("C:\test.swf"); // Create the FileInputStream&lt;br /&gt;  decoder = createObject("java", "macromedia.swf.TagDecoder").init(fis); // create TagDecoder&lt;br /&gt;  header = decoder.decodeHeader(); // Decode the header.&lt;br /&gt;  fis.close();&lt;br /&gt;  rect = header.size;&lt;br /&gt;  WriteOutput("&lt;br /&gt;    Is Compressed : #header.compressed#&amp;lt;br&amp;gt;&lt;br /&gt;    Frame Count : #header.framecount#&amp;lt;br&amp;gt;&lt;br /&gt;    Frame rate : #header.rate#&amp;lt;br&amp;gt;&lt;br /&gt;    Version : #header.version#&amp;lt;br&amp;gt;&lt;br /&gt;    Height : #rect.getHeight()#&amp;lt;br&amp;gt;&lt;br /&gt;    Width : #rect.getWidth()#");&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;The height and width value that you see here would be in &lt;a href="http://en.wikipedia.org/wiki/Twips"&gt;twips&lt;/a&gt; which is defined as 1/20 of a point or 1/1440 inch. This means, for a 72 dpi screeen, you will have to divide it by 20 to get the height and width in pixels.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-4199988373427570984?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/4199988373427570984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=4199988373427570984' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4199988373427570984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4199988373427570984'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/02/reading-flash-swf-metadata-from.html' title='Reading Flash (Swf) metadata from ColdFusion'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-502023548328701732</id><published>2008-01-14T10:55:00.001-08:00</published><updated>2008-01-14T10:55:57.253-08:00</updated><title type='text'>Adobe ColdFusion Survey</title><content type='html'>&lt;p&gt;As promised &lt;a href="http://coldfused.blogspot.com/2008/01/adobe-coldfusion-ide-survey.html"&gt;earlier&lt;/a&gt;, here they come. As part of the research for Centaur (next major version of ColdFusion aka ColdFusion 9), we need your feedback on ColdFusion 8 features, what enhancements do you need in them, what new features you want in the new release etc etc. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.surveymonkey.com/s.aspx?sm=yLcENFTqjkIn6gqoFpRiUQ_3d_3d"&gt;Adobe ColdFusion Survey&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We would also like your inputs on platform and vendor support for upcoming ColdFusion release.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.surveymonkey.com/s.aspx?sm=_2fJgulePMz_2f1GM6FGV6uMUQ_3d_3d"&gt;Platform and Vendor Support&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Please do take some time to take this survey as this would really help us shape the new features in the upcoming version. THIS is YOUR chance to get your favorite features in !&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-502023548328701732?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/502023548328701732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=502023548328701732' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/502023548328701732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/502023548328701732'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/01/adobe-coldfusion-survey.html' title='Adobe ColdFusion Survey'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-6901901686756851815</id><published>2008-01-10T11:22:00.001-08:00</published><updated>2008-01-10T22:34:29.485-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='Network'/><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='caching'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>DNS lookup Caching in ColdFusion/Java</title><content type='html'>&lt;p&gt;Two days back, I got an interesting question from our support team. The Customer in this case was using CFLdap which connected to a particular LDAP server and things were working fine. The problem came when they replaced this LDAP server with another LDAP server and assigned the same dns name to the new ldap server. Ideally any connection made henceforth should have worked with the new ldap server but actually that did not happen. ColdFusion started throwing error and it did not work until the ColdFusion server is restarted. Ever seen something similar?&lt;/p&gt;  &lt;p&gt;It is obvious that it happend because the IP address was being cached for the host name as a result of which ColdFusion was still trying to connect to the old IP address even though the host name now pointed to a different IP address. This caching also applies for all other network protocol tags such as CFHTTP, CFFTP, CFFEED etc and is not limited to CFLDAP. It is actually the JVM that does this caching. When JVM is requested to resolve a host name, it does the host name to IP address resolution and caches the result. This result will be used for all subsequent lookups. It also caches the negative results. By that I mean, if the dns reolution fails, it caches the failed result for a certain period so that any lookup for that hostname in that period will not result into another resolution on network and will immediately return the failed result.&lt;/p&gt;  &lt;p&gt;For more detail on this caching, check out the &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/net/InetAddress.html"&gt;Javadoc for InetAddress&lt;/a&gt; class.&lt;/p&gt;  &lt;p&gt;As per this doc, there are two parameters that control this caching&lt;/p&gt;  &lt;blockquote&gt;&lt;dl&gt;&lt;dt&gt;&lt;b&gt;networkaddress.cache.ttl&lt;/b&gt; (default: -1) &lt;/dt&gt;&lt;dd&gt;Indicates the caching policy for successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the successful lookup.        &lt;p&gt;A value of -1 indicates "cache forever". &lt;/p&gt;        &lt;p&gt;&lt;/p&gt;     &lt;/dd&gt;&lt;dt&gt;&lt;b&gt;networkaddress.cache.negative.ttl&lt;/b&gt; (default: 10) &lt;/dt&gt;&lt;dd&gt;Indicates the caching policy for un-successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the failure for un-successful lookups.        &lt;p&gt;A value of 0 indicates "never cache". A value of -1 indicates "cache forever". &lt;/p&gt;     &lt;/dd&gt;&lt;/dl&gt;&lt;/blockquote&gt; &lt;dl&gt;&lt;dt&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;&lt;/dt&gt;&lt;/dl&gt;  &lt;p&gt;Now where do you specify this settying? You can specify this setting in &lt;strong&gt;&amp;lt;Java_home&amp;gt;/jre/lib/security/java.security&lt;/strong&gt; file. For standalone ColdFusion server it will be in &amp;lt;ColdFusion _dir&amp;gt;/runtime/jre/lib/security/java.security file. &lt;/p&gt;  &lt;p&gt;As you see, by default &lt;strong&gt;networkaddress.cache.ttl&lt;/strong&gt; caches the result for ever and hence it is configured for best performance. Any change to this mean drop in performance. If you don't want to cache the resolved IP address for ever, as is the case here, you would need to change &lt;strong&gt;networkaddress.cache.ttl&lt;/strong&gt; value to 60 seconds or 300 seconds or any value you feel suitable. You would not want to set it to 0 as that would mean "never cache" the result which might affect the performance significantly.&lt;/p&gt;  &lt;p&gt;In which case you would want to change the value for &lt;strong&gt;networkaddress.cache.negative.ttl&lt;/strong&gt;? That would be mostly in case when you want to cache the negative result for a longer time and in turn improving the performance. For example, if you are trying to connect to a hostname which can not be resolved to any ip address, and that happens very frequently, each of the call (as long as they are not in the same 10 sec window) would become very slow. Increasing this value would increase the performance but again you would not want to cache the negative result for ever.&lt;/p&gt;  &lt;p&gt;After you change this setting, you will have to restart the ColdFusion server for this change to take effect.   &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-6901901686756851815?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/6901901686756851815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=6901901686756851815' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6901901686756851815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6901901686756851815'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/01/dns-lookup-caching-in-coldfusionjava.html' title='DNS lookup Caching in ColdFusion/Java'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5054492512922765427</id><published>2008-01-07T08:50:00.001-08:00</published><updated>2008-01-10T22:33:03.619-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><title type='text'>ColdFusion 8 finalist among Dr. Dobb's Jolt Product Excellence Awards</title><content type='html'>&lt;p&gt;Good to see ColdFusion 8 as a finalist in Web Development tools category among Dr. Dobb's 18th Annual Jolt Product Excellence Awards. &lt;a href="http://www.reuters.com/article/pressRelease/idUS120469+07-Jan-2008+PRN20080107"&gt;Here is the entire story&lt;/a&gt; and &lt;a href="http://www.joltawards.com/finalists.html"&gt;here&lt;/a&gt; is the list of finalists.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5054492512922765427?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5054492512922765427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5054492512922765427' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5054492512922765427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5054492512922765427'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/01/coldfusion-8-finalist-among-dr-dobb.html' title='ColdFusion 8 finalist among Dr. Dobb&amp;#39;s Jolt Product Excellence Awards'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3085010731018438017</id><published>2008-01-07T08:07:00.001-08:00</published><updated>2008-01-10T22:33:03.620-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><title type='text'>Adobe ColdFusion IDE Survey</title><content type='html'>&lt;p&gt;As part of our research on CF9 (Centaur), the ColdFusion team has come up with a survey to find out what features do you use and would like to have in an IDE for Coldfusion. Please take few minutes to take this quick survey.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.surveymonkey.com/s.aspx?sm=321RrO9_2fWaP_2bdYMnmF9CuQ_3d_3d"&gt;http://www.surveymonkey.com/s.aspx?sm=321RrO9_2fWaP_2bdYMnmF9CuQ_3d_3d&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Check out this space in few days for another survey to tell us what you would want to see in CF 9 !&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3085010731018438017?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3085010731018438017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3085010731018438017' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3085010731018438017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3085010731018438017'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/01/adobe-coldfusion-ide-survey.html' title='Adobe ColdFusion IDE Survey'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5967422997328867700</id><published>2008-01-02T08:49:00.001-08:00</published><updated>2008-01-10T22:31:44.438-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><title type='text'>Encrypted CFML Templates</title><content type='html'>&lt;p&gt;Coming back from the 10 days shutdown period that we had at Adobe, I am catching up with the blogs and I read &lt;a href="http://www.coldfusionjedi.com/index.cfm/2007/12/28/Ive-decrypted-my-CFML-templates-and-lost-the-originals-now-what"&gt;this interesting post&lt;/a&gt; by &lt;a href="http://www.coldfusionjedi.com"&gt;Ray&lt;/a&gt; where he mentioned that some one got his cfml templates encrypted and then lost the originals. Hmmm.. that is a situation, I would never want to be in. In case you have not figured it out yet, it is not possible to get back the original source. Let me explain.&lt;/p&gt;  &lt;p&gt;Why do we need to encrypt cfml templates? To protect the cfml code and your intellectual properties (IP) in case you want to distribute your CF application. Right? In pre-CFMX7 era, ColdFusion used to have &amp;quot;cfencode&amp;quot; utility which used to encrypt the template which you can then distribute to anyone. ColdFusion used to know how to decrypt that and then how to execute that. However, this was not a good solution as people came up with utility to decode this encrypted file. And THAT means that&amp;#160; your code and IP was not protected at all. This had another disadvantage - template execution was slower as it meant decrypting the template first and then compiling/executing it.&lt;/p&gt;  &lt;p&gt;With CFMX7, this changed. ColdFusion came up with sourceless deployment to make it nearly impossible to decode it back to the original source. When you use '&lt;a href="http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&amp;amp;file=00001762.htm"&gt;cfcompile&lt;/a&gt;' with deploy option, your cfml template is compiled to java byte code (class) but the file in which this byte code is written still retains the same template name. To give an example, if you run cfcompile on &amp;quot;hello.cfm&amp;quot;, the output would still be &amp;quot;hello.cfm&amp;quot; but it will actually be java class file. To confirm this, just open one of such encrypted file in a hex editor and you would see the first 8 bytes will be CAFEBABE - the magic number for java class files. This file can then be distributed to your customers. For execution, ColdFusion works smart - when request comes for this template, it sees that it is not a cfml template but a class file, skips parsing and compiling the template, and directly proceeds with the execution. &lt;/p&gt;  &lt;p&gt;As you see, there is no encryption and no key involved here. The encrypted file is simply a java class file and I have not heard of any utility that can decompile this class file back to cfm source. Though there are many Java decompilers available which can convert the class file to approximate java source file, it will be a huge huge task to write a decompiler which can generate cfm code for class file. One needs to know how CF does the code generation, know a great deal about bytecode instructions and apply lots and lots of heuristic to get the approximate cfm source. This is definitely not an easy thing to do even if some one breaks open the CF engine to see how it generates the java code from cfm code.&lt;/p&gt;  &lt;p&gt;The bottom line is - in case you use sourceless deployment, ALWAYS backup your original source.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5967422997328867700?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5967422997328867700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5967422997328867700' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5967422997328867700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5967422997328867700'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2008/01/encrypted-cfml-templates.html' title='Encrypted CFML Templates'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-7160793675689159551</id><published>2007-12-19T11:39:00.001-08:00</published><updated>2007-12-19T11:39:47.885-08:00</updated><title type='text'>Google to roll out wikipedia rival - Google Knol</title><content type='html'>&lt;p&gt;Google is coming out with Google Knol (Knowledge) which is exactly what Wikipedia is all about. Read on &lt;/p&gt;  &lt;p&gt;&lt;a title="http://googleblog.blogspot.com/2007/12/encouraging-people-to-contribute.html" href="http://googleblog.blogspot.com/2007/12/encouraging-people-to-contribute.html"&gt;http://googleblog.blogspot.com/2007/12/encouraging-people-to-contribute.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://searchengineland.com/071213-213400.php" href="http://searchengineland.com/071213-213400.php"&gt;http://searchengineland.com/071213-213400.php&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-7160793675689159551?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/7160793675689159551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=7160793675689159551' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/7160793675689159551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/7160793675689159551'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/12/google-to-roll-out-wikipedia-rival.html' title='Google to roll out wikipedia rival - Google Knol'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-1890857784566372447</id><published>2007-12-14T14:29:00.001-08:00</published><updated>2007-12-14T14:29:11.817-08:00</updated><title type='text'>Firefox (Adblock plus) blocks even Google adsense</title><content type='html'>&lt;p&gt;I have been using my new laptop at work (my old one &lt;a href="http://coldfused.blogspot.com/2007/10/week-at-max.html"&gt;crashed at MAX&lt;/a&gt;) for two weeks and its been pretty good. Not because the laptop is something extraordinary, its because I installed the latest versions of all the softwares and plugins I use. And the most pleasant part of it is - it has been completely ads free. I did not notice it earlier but once I landed up on sys-con's site to read some article and I was pleasantly surprised to find no irritating video ad there. For a moment, I thought that may be sys-con has grown up but that was just for a moment :-). The snapshot shows it all.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;IE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.google.com/rupeshk/R2MDhywzORI/AAAAAAAAABs/cQks7-UIPVY/cfdj_ie_1%5B5%5D"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="323" alt="cfdj_ie_1" src="http://lh4.google.com/rupeshk/R2MDkSwzOSI/AAAAAAAAAB0/xyxiUSIwZfU/cfdj_ie_1_thumb%5B3%5D" width="528" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Firefox&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.google.com/rupeshk/R2MDmCwzOTI/AAAAAAAAAB8/knolMQj_Gp0/cfdj_firefox_1%5B5%5D"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="312" alt="cfdj_firefox_1" src="http://lh3.google.com/rupeshk/R2MDpCwzOUI/AAAAAAAAACE/KX4aUnyiotM/cfdj_firefox_1_thumb%5B3%5D" width="531" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Its actually a firefox plugin &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/1865"&gt;adblock plus&lt;/a&gt; that does it automatically. The most interesting thing was that it even removed google text ads. Its interesting because we have always seen Google promoting firefox and firefox as a browser closer to Google. So now a firefox plugin that blocks google adsense and in turn hurts Google revenue is certainly not going to go well with Google. It will be interesting to see how Google plays it. &lt;/p&gt;  &lt;p&gt;So how exactly does adblock plus block the ads? Gecko engine - the engine underneath Firefox, uses a content policy which decides which content should be loaded and which should not. Adblock defines its own policy which gets added to the browser's policy. It comes with a predefined huge collection of filters and if the url to be loaded matches any of that, it does not let the browser make a request for it. For google adsense, the url contains 'pagead2' which you can see in the adblock preference below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.google.com/rupeshk/R2MDriwzOVI/AAAAAAAAACM/Q4I38ifCD5c/adp%5B5%5D"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="337" alt="adp" src="http://lh3.google.com/rupeshk/R2MDtCwzOWI/AAAAAAAAACU/zkotLSINBS8/adp_thumb%5B3%5D" width="533" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Its also going to hurt many bloggers as lot of them earn substantially from ads and mainly adsense.&amp;#160; Even my blog page contains adsense but I dont mind adblock plus as I haven't yet earned anything from it anyway. I'm loving it. :-)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-1890857784566372447?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/1890857784566372447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=1890857784566372447' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/1890857784566372447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/1890857784566372447'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/12/firefox-adblock-plus-blocks-even-google.html' title='Firefox (Adblock plus) blocks even Google adsense'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-6301295686679386319</id><published>2007-12-14T12:31:00.001-08:00</published><updated>2007-12-14T12:36:20.741-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Images and CFDocument performance</title><content type='html'>Sometime back one of our customer reported that using png images in cfdocument makes it very very slow. I could not replicate it with any png image but it did happen with his &lt;a href="http://www.welshkatz.com/1652BE/print/Masthead.png"&gt;png image&lt;/a&gt;.   &lt;p&gt;Today, Andy reported a &lt;a href="http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:54540"&gt;similar issue&lt;/a&gt; but this time it was for jpeg images. In both the cases, performance hit is huge and it does not happen with all the images. &lt;/p&gt;  &lt;p&gt;I spent a significant amount of time debugging it today and it turns out that the reason for both the issues are same - there is something special about these images and that is &lt;a href="http://en.wikipedia.org/wiki/Colorspace"&gt;colorspace&lt;/a&gt;. All these images actually had a different colorspace than what java imaging uses. Because of this, when we need the pixel values of image to print it on pdf (by calling BufferedImage.getRGB()), it tries to convert this colorspace to RGB colorspace and that is very very costly. That is where the entire time goes. So how do you fix it? I opened all the images in an image editor and saved it again. This time it got saved in standard RGB colorspace and the time taken to create the pdf got reduced from 110 sec to 1.5 seconds. That is huge!!! Isn't it? But can you control all the images over the web? NO.. right? Read on.. there is more to this story. &lt;/p&gt;  &lt;p&gt;A little bit of looking up on web pointed me to &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4705399"&gt;this Sun bug&lt;/a&gt; which is the exact same bug which we were hitting. Thankfully it got fixed in mustang i.e JDK1.6 which ColdFusion8 uses by default. But hey wait a second.. Didn't Andy say that he is seeing it on ColdFusion 8? why do we still see this happening when it is fixed in JDK1.6? It appears that this bug was fixed only in core JDK api but not in JAI (Java advanced imaging) codecLib that ColdFusion 8 uses. So what do we do now? You can do either of these two &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Remove clibwrapper_jiio.jar from "lib" folder. &lt;/li&gt;    &lt;li&gt;Or, set this system property to the JVM. &lt;b&gt;&lt;span style="font-family:courier;"&gt;-Dcom.sun.media.imageio.disableCodecLib=true&lt;/span&gt;&lt;/b&gt; . You can set this in [cf-install_dir]/runtime/bin/jvm.config if you are using standalone coldfusion server. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;You should keep in mind that codecLib libraries are native libraries which are meant to increase the java imaging performance. So disabling it might degrade the performance of CFImage somewhere. Also keep in mind that removing this jar or disabling codecLib will not result into any loss of functionality - it just means that all image operations will be pure java. &lt;/p&gt;  &lt;p&gt;There is &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6529318"&gt;another related Sun's bug&lt;/a&gt; which I thought might be useful to you. Image loading might get very slow if the server is running in debug mode. Your server is running in debug mode if you see something like this in your jvm.config or VM startup option.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre&gt;&lt;div class="code"&gt;-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005&lt;/div&gt;&lt;/pre&gt;This bug got introduced in JDK1.6 and does not exist on 1.5. So make sure that you are not running the server in debug mode.&lt;br /&gt;&lt;br /&gt;To summarise, you can do following to increase the performance of image loading in cfdocument.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;If you are on JDK1.5, there is not much you can do. The only option is to change the colorspace of images. I will try to see if we can address this in ColdFusion code. &lt;/li&gt;  &lt;li&gt;If you are on JDK1.6,&lt;br /&gt;    &lt;ul&gt;&lt;li&gt;Disable codecLib as mentioned above. &lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;      &lt;/ol&gt;&lt;ul&gt;&lt;li&gt;Disable debug mode by removing the complete debug string mentioned above &lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;    &lt;/ol&gt;  &lt;/li&gt;  &lt;li&gt;In addition to this, you might want to use 'localurl' attribute for cfdocument tag. &lt;a href="http://coldfused.blogspot.com/2007/07/enhancements-to-cfdocument-in.html"&gt;See this&lt;/a&gt; for more details. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-6301295686679386319?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/6301295686679386319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=6301295686679386319' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6301295686679386319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6301295686679386319'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/12/images-and-cfdocument-performance.html' title='Images and CFDocument performance'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-1751508310693171479</id><published>2007-12-12T10:27:00.001-08:00</published><updated>2007-12-12T10:31:15.759-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='pdf'/><title type='text'>Missing text in pdf created by CFDocument</title><content type='html'>&lt;p&gt;I had heard about people not getting images in the generated pdf but this one was something new and spooky. Yesterday &lt;a href="http://www.commadelimited.com/"&gt;Andy Matthews&lt;/a&gt; &lt;a href="http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:54485"&gt;posted&lt;/a&gt; it on cf-talk where he says that for his content, though a pdf containing 15 pages gets created but only the first page has some content and rest of the pages are blank. I ran his code on my machine and sure enough it was happening. All the content including text and image on all the pages except the first page was gone. So what was wrong? I simplified his code and here is a simple example which you can try.&lt;/p&gt;  &lt;pre&gt;&lt;div class="code"&gt;&amp;lt;cfdocument format="pdf"&amp;gt;&lt;br /&gt;Text Outside div&lt;br /&gt;&amp;lt;div style="width:300px;overflow:auto;"&amp;gt;&lt;br /&gt; This is text inside the div. Will it show up?&lt;br /&gt;&amp;lt;/div&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;In the generated pdf you will see only "Text Outside div". Spooky.. isn't it? The reason it happened was because of css style &lt;strong&gt;'overflow:auto'&lt;/strong&gt;. The rendering engine used by CFDocument underneath does not handle overflow:auto and it simply ignores the content in the div. The weird part is - it considers that content for all rendering calculations including page number and page break calculation. &lt;p&gt;Something you should watch out for if you use css styles in cfdocument. A workaround for the time being is not to use overflow:auto style. So modifying the above code like this will make it work.&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&lt;div class="code"&gt;&amp;lt;cfdocument format="pdf"&amp;gt;&lt;br /&gt;Text Outside div&lt;br /&gt;&amp;lt;div style="width:300px;"&amp;gt;&lt;br /&gt; This is text inside the div. Will it show up?&lt;br /&gt;&amp;lt;/div&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-1751508310693171479?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/1751508310693171479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=1751508310693171479' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/1751508310693171479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/1751508310693171479'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/12/missing-text-in-pdf-created-by.html' title='Missing text in pdf created by CFDocument'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-378337469470140296</id><published>2007-11-21T08:04:00.001-08:00</published><updated>2008-01-10T22:33:03.620-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><title type='text'>64 bit Support on ColdFusion 8 (Windows, Linux and Leopard)</title><content type='html'>&lt;p&gt;ColdFusion team is working to get ColdFusion 8 working on 64 Bit platforms(Windows, Linux and Leopard). If you are interested and want to participate in the testing of early releases of 64 Bit support on ColdFusion 8 on these platforms, please enroll yourself for prerelease program &lt;a href="http://www.adobe.com/cfusion/mmform/index.cfm?name=prerelease_interest"&gt;here&lt;/a&gt;. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-378337469470140296?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/378337469470140296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=378337469470140296' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/378337469470140296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/378337469470140296'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/11/64-bit-support-on-coldfusion-8-windows.html' title='64 bit Support on ColdFusion 8 (Windows, Linux and Leopard)'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3679220311384027728</id><published>2007-11-21T08:02:00.001-08:00</published><updated>2008-01-10T22:35:05.404-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jrun'/><title type='text'>JRun updater 7 released</title><content type='html'>&lt;p&gt;JRun 4 updater 7 got released last week and is publicly &lt;a href="http://www.adobe.com/support/jrun/updaters.html"&gt;available for download&lt;/a&gt;. It now supports a host of new platforms, includes upgrades to existing software components and fixes for many critical bugs.&lt;/p&gt;  &lt;p&gt;Some of the important platform support include&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;JDK 1.6 support&lt;/li&gt;    &lt;li&gt;Support for Windows Vista.&lt;/li&gt;    &lt;li&gt;Mac OS X 10.4 on Intel &lt;/li&gt;    &lt;li&gt;64-bit Support on Solaris-SPARC. &lt;/li&gt;    &lt;li&gt;IIS7 support.&lt;/li&gt;    &lt;li&gt;Apache 2.2.x support &lt;/li&gt;    &lt;li&gt;SunOne Webserver 7&lt;/li&gt;    &lt;li&gt;IBM JDK 1.5&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Another important reason why you might want this is - a very significant performance improvement in web clustering. Check out the detailed &lt;a href="http://www.adobe.com/support/documentation/en/jrun/4/updater7/releasenotes_4_updater7.pdf"&gt;release notes here&lt;/a&gt;. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3679220311384027728?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3679220311384027728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3679220311384027728' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3679220311384027728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3679220311384027728'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/11/jrun-updater-7-released.html' title='JRun updater 7 released'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8205499757411466625</id><published>2007-10-10T02:38:00.001-07:00</published><updated>2008-01-10T22:35:24.116-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='MAX'/><title type='text'>The Week at Max</title><content type='html'>&lt;p&gt;Wow ! What an incredible week it was. A week that saw the largest ever MAX, a week that saw the largest get together of ColdFusion community, a week that&amp;nbsp;saw the best ever&amp;nbsp;visibility of CF at MAX general sessions, a week that saw U2's Bono (err.. his fake??)&amp;nbsp;having fun at a tech conference like MAX and a week that saw lot of cool&amp;nbsp;and amazing Adobe technologies shaping up. &lt;/p&gt; &lt;p&gt;It also had moments of a Hollywood thriller for me. I was presenting a session on "Leveraging ColdFusion&amp;nbsp;for AIR application". My first session was on Tuesday, 2nd October at 4 o'clock and at around 2 o'clock my laptop crashed and after that it just refused to&amp;nbsp;boot up. Luckily I had the backup of my ppt and some demo files and hence I decided to use Sanjeev's (Pdf and compiler guy in the CF team)&amp;nbsp;laptop to make the presentation. I just had one and half hour and&amp;nbsp;I needed to setup everything back on his machine - install the air runtime, air sdk, cfeclipse, copy all my files etc and keep the setup ready to run whatever demos I was left with.&amp;nbsp;To add to this, somehow there was no Internet available in the conference area - So where to get AIR runtime and SDK from? Sanjeev suggested that may be AIR guys might have it and&amp;nbsp;so we ran across to the AIR park to get those on my flash drive. I can't tell you what those one and half hour were like :-). I barely managed to get the presentation ready in time and thankfully the presentation went well. &lt;/p&gt; &lt;p&gt;As if this was not enough, the adventure continued for the repeat session as well. No this time the laptop didn't crash.. but this time I could not find Sanjeev so that I could take the laptop from him. I just had&amp;nbsp;half an hour left for the session and I did not have any laptop. And I didn't even have the patience for setting it all up once again on another laptop. Finally found him just 15 minutes before my session while he was chatting with BEA guys. phew.. &lt;/p&gt; &lt;p&gt;Anyway, &lt;a href="http://rupeshk.org/preso/Max07" target="_blank"&gt;here&lt;/a&gt; is my presentation and some of the demo files if you are interested to take a look at that. I could not upload it earlier as I got a temporary laptop just yesterday. I will upload the flex part of demo in a day or two.&lt;/p&gt; &lt;p&gt;If you were there at MAX, you must have seen Hemant talking about &lt;a href="http://www.brooks-bilson.com/blogs/rob/index.cfm/2007/10/2/Adobe-MAX-2007--Sneak-Peeks-Part-2-ColdFusion-Offline-Apps-Here" target="_blank"&gt;ColdFusion and AIR at sneak peek&lt;/a&gt;. Though this was just a prototype, it surely gives an idea what can be&amp;nbsp;done in CF for air apps. It would be great if you can share what exactly or what else would you like to see in ColdFusion&amp;nbsp;to help you build AIR application easily. Thoughts??&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8205499757411466625?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8205499757411466625/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8205499757411466625' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8205499757411466625'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8205499757411466625'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/10/week-at-max.html' title='The Week at Max'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-4077411167375534116</id><published>2007-09-20T09:47:00.001-07:00</published><updated>2008-01-10T22:31:04.540-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><title type='text'>CFDocument hotfix for ColdFusion 8 released</title><content type='html'>&lt;p&gt;We have released a &lt;a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402584&amp;amp;sliceId=1" target="_blank"&gt;cumulative hotfix&lt;/a&gt; for CFDocument related issues in ColdFusion 8. Bugs being addressed in this hotfix are&lt;/p&gt; &lt;ul&gt; &lt;li&gt;PDF/Flashpaper document generated in CF8 are nearly 70% scaled down than CFMX 7. This was making document appear smaller in CF8 as compared to CF7.&lt;/li&gt; &lt;li&gt;Using cfdocumentitem in a loop inside cfdocument causes the error, "routines cannot be declared more than once".&lt;/li&gt; &lt;li&gt;StackOverFlowError when a large document with table is created. A simple report with over 1500 table row causes this problem. More complex, but shorter documents have also resulted in this error. This was a pretty nasty one and it deserves a separate blog entry :-).&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;You can download the hotfix directly from &lt;a href="http://www.adobe.com/support/coldfusion/ts/documents/kb402584/hf800-70403.zip" target="_blank"&gt;here&lt;/a&gt;. You would need to extract the hotfix jar from the downloaded zip file and apply that jar. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-4077411167375534116?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/4077411167375534116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=4077411167375534116' title='17 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4077411167375534116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4077411167375534116'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/09/cfdocument-hotfix-for-coldfusion-8.html' title='CFDocument hotfix for ColdFusion 8 released'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>17</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-4362633748903329545</id><published>2007-08-16T10:31:00.001-07:00</published><updated>2007-12-19T12:47:58.545-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='file upload'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>ColdFusion 8 : Changes with File Upload</title><content type='html'>&lt;p&gt;Till ColdFusion 7, it was not possible to upload a large file. The server could not handle uploading a file of probably anything more than 300-400 MB. And on top of that, if there are multiple people trying to upload large files simultaneously to the server, only thing that you can do is to pray :-)&lt;/p&gt; &lt;p&gt;You might wonder and I agree with you, that its a huge limitation. So why was it this way ? Well.. that was because the server had to keep the entire uploaded file in the memory. Whoa.. Why the heck does the server need to keep the entire uploaded file in memory? - For a single reason of serving the function GetHttpRequestData(). As you know, this function returns a 'struct' containing the metadata for the Http request that comes to the server. Since this struct also includes request body, and the uploaded file is part of the request, the file has to be retained in the memory in order to honor this function.&lt;/p&gt; &lt;p&gt;With ColdFusion 8, we have removed the limitation on file upload size. So now you can upload files of any size without causing any issue with the server. I have successfully tried with 5 GB file because that was the biggest I could get hold of but you can absolutely upload files of any size. ColdFusion nicely handles it, reads it the way it should without requiring much memory. &lt;/p&gt; &lt;p&gt;But hey, hold on a sec.. What about the function GetHttpRequestData()? Wasn't that the reason for this limitation in the first place? Well, the function GetHttpRequestData() works perfectly fine except in this one case - In the multipart request, i.e; request in which a file is uploaded - "content" in the returned struct will be empty. If you need to get the uploaded file content in memory, you can always read the uploaded file and keep it in memory. So that should not be much we are asking for. Are we?&lt;/p&gt; &lt;p&gt;If in case, you absolutely want the content from GetHttpRequestData() and file upload size is of no concern to you, we allow you to revert back to ColdFusion 7 behaviour. All you need to do for this is to set the Java system property "&lt;span style="font-weight: bold;"&gt;coldfusion.markResetForMultiPart&lt;/span&gt;" to "true" and you are back to the old behavior.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-4362633748903329545?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/4362633748903329545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=4362633748903329545' title='38 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4362633748903329545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4362633748903329545'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/08/coldfusion-8-changes-with-file-upload.html' title='ColdFusion 8 : Changes with File Upload'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>38</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-127344320710762368</id><published>2007-08-09T11:54:00.001-07:00</published><updated>2007-08-09T11:54:58.096-07:00</updated><title type='text'>Unlimited aliases with Gmail and SPAM protection</title><content type='html'>&lt;p&gt;Though this hack in Gmail has been known for a while, I read about it today and found it interesting enough to share it.&amp;nbsp;As &lt;a href="http://labnol.blogspot.com/2006/09/gmail-easter-eggs-dot-blindess-email.html" target="_blank"&gt;Amit&lt;/a&gt; decribes in his post, GMAIL lets you create unlimited number of aliases for your gmail id and&amp;nbsp;you can then give these aliases on other websites without worrying about spams. The trick is to use '+' addressing!&lt;/p&gt; &lt;p&gt;As he says, gmail ignores anything between '+' and &lt;a href="mailto:'@'"&gt;'@'&lt;/a&gt; in the email address. So a mail sent to &lt;a href="mailto:paris.hilton+model@gmail.com"&gt;paris.hilton+model@gmail.com&lt;/a&gt; or &lt;a href="mailto:paris.hilton+celebrity@gmail.com"&gt;paris.hilton+celebrity@gmail.com&lt;/a&gt;&amp;nbsp;will all go to &lt;a href="mailto:paris.hilton@gmail.com"&gt;paris.hilton@gmail.com&lt;/a&gt;. In the received mail, "To"&amp;nbsp;will still point to the original id to which it was sent which makes it easy to create spam filters based on the 'To' address. If used intelligently, you also get to know which site leaks your address and creates SPAM. So, if I have to give my mail id to any website&amp;nbsp;xyz.com, I can give &lt;a href="mailto:'mymailid+xyz@gmail.com'"&gt;'mymailid+xyz@gmail.com'&lt;/a&gt;. If I get the spam with 'to' address as &lt;a href="mailto:mymailid+xyz@gmail.com"&gt;mymailid+xyz@gmail.com&lt;/a&gt;, I get to know that its xyz.com that had leaked the id and creates spam.&amp;nbsp; Pretty cool..&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-127344320710762368?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/127344320710762368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=127344320710762368' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/127344320710762368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/127344320710762368'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/08/unlimited-aliases-with-gmail-and-spam.html' title='Unlimited aliases with Gmail and SPAM protection'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3878078911052224609</id><published>2007-08-08T12:39:00.001-07:00</published><updated>2008-01-10T22:33:53.349-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='WebService'/><title type='text'>ColdFusion and WebService : "class file has wrong version"</title><content type='html'>&lt;p&gt;I can't even count the number of times I have seen this error while QA folks were running webservices regressions for ColdFusion 8. Everytime, someone was running webservices tests on a J2EE configuration they used to get an error :&lt;/p&gt; &lt;p&gt;&lt;em&gt;coldfusion.jsp.CompilationFailedException: Errors reported by Java compiler:&lt;br&gt;....&lt;br&gt;class file has wrong version 49.0, should be 48.0&lt;/em&gt;&lt;/p&gt; &lt;p&gt;I saw the same error posted in the public forum where the user had deployed ColdFusion 8 on JRun with JDK1.5 and was trying to invoke webservice. And hence this blog entry :-)&lt;/p&gt; &lt;p&gt;This error comes because of incompatibility between the tools.jar and the JVM version. ColdFusion 8 ships Java 1.6's tools.jar (you will find it in cfusion/lib) which is of course incompatible with any other JDK/JRE version. You will see the same behavior with ColdFusion 7 as well, if you run it on a JVM other than 1.4. So the rule of thumb is - if ColdFusion is running on a JVM version other than the shipped one, you must ensure that the tools.jar is in synch. In short, you will need to copy JDK's tools.jar to cfusion/lib.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3878078911052224609?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3878078911052224609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3878078911052224609' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3878078911052224609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3878078911052224609'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/08/coldfusion-and-webservice-file-has.html' title='ColdFusion and WebService : &amp;quot;class file has wrong version&amp;quot;'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8221691905724260237</id><published>2007-08-03T07:49:00.001-07:00</published><updated>2007-08-03T07:51:00.212-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Using CFFeed with URL sending compressed content</title><content type='html'>&lt;p&gt;Today someone posted on ColdFusion forum regarding this problem where cffeed was not able to handle a particular URL and it was throwing an error. The URL which he tried was &lt;a href="http://movies.msn.com/rss/topcelebs"&gt;http://movies.msn.com/rss/topcelebs&lt;/a&gt; and it failed with an error &lt;/p&gt; &lt;p&gt;"&lt;em&gt;Unable to read the source URL.&lt;br /&gt;unknown compression method&lt;/em&gt;"  &lt;/p&gt;&lt;p&gt;The reason it happens is - The URL returns the response in gzip compressed format only. So when ColdFusion sent a request to this URL and asked for uncompressed data, it could not get anything and hence it was unable to read it. A simpe workaround for this is to use cfhttp to fetch the content, write to a temporary file and then use the cffeed tag to read this file. Important thing to keep in mind here is to set an additional header in the cfhttp tag using cfhttpparam to indicate that it can accept compressed data as well.&lt;/p&gt; &lt;p&gt;Here is the modified code where it first tries cffeed with the URL. If that fails, then it tries to use cfhttp to fetch the content and writes to a temporary file and then uses it in cffeed.&lt;/p&gt;&lt;pre&gt;&lt;div class="code"&gt;&amp;lt;cfset tempDir=GetTempDirectory()&amp;gt;&lt;br /&gt;&amp;lt;cfset tempFile = GetTempFile(tempDir, "myfeed")&amp;gt;&lt;br /&gt;&amp;lt;cfset tempFileName = GetFileInfo(tempFile).name&amp;gt;&lt;br /&gt;&lt;p&gt;&amp;lt;cftry&amp;gt;&lt;br /&gt;    &amp;lt;cffeed action="read" source="http://movies.msn.com/rss/topcelebs" name="feedInStruct" &amp;gt;&lt;br /&gt;&amp;lt;cfcatch any&amp;gt;&lt;br /&gt;    &amp;lt;cfhttp url="http://movies.msn.com/rss/topcelebs" path="#tempDir#" file="#tempFileName#"&amp;gt;&lt;br /&gt;        &amp;lt;cfhttpparam type="header" name="Accept-Encoding" value="compress,gzip,deflate"&amp;gt;&lt;br /&gt;    &amp;lt;/cfhttp&amp;gt;&lt;br /&gt;    &amp;lt;cffeed action="read" source="#tempFile#" name="feedInStruct" &amp;gt;&lt;br /&gt;&amp;lt;/cfcatch&amp;gt;&lt;br /&gt;&amp;lt;/cftry&amp;gt;&lt;br /&gt;&amp;lt;cfif FileExists(tempFile)&amp;gt;&lt;br /&gt;    &amp;lt;cfset FileDelete(tempFile)&amp;gt;&lt;br /&gt;&amp;lt;/cfif&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cfdump var="#feedInStruct#"&amp;gt;&lt;/p&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8221691905724260237?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8221691905724260237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8221691905724260237' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8221691905724260237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8221691905724260237'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/08/using-cffeed-with-url-sending.html' title='Using CFFeed with URL sending compressed content'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-9065885839121555236</id><published>2007-08-02T08:52:00.001-07:00</published><updated>2007-08-02T09:08:36.224-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>ColdFusion 8 : IsInstanceOf</title><content type='html'>&lt;p&gt;If you use lot of CFC inside your ColdFusion application, I am sure you would have come across a situation where you would need to know whether the object is an instance of a particular CFC. This is specially needed when you have components extending other component or you are passing the objects around. ColdFusion 8 introduces a new function &lt;strong&gt;IsInstanceOf&lt;/strong&gt; to do exactly the same. It becomes even more useful after we have interfaces in ColdFusion. And the icing on the cake is that it works even with java objects which means that you can use this function to find out if a particular object is of a particular java class type.&lt;/p&gt; &lt;p&gt;Here is how the function looks.&lt;/p&gt;&lt;pre&gt;IsInstanceOf(object, typeName)&lt;/pre&gt;&lt;p&gt;where typeName is name of the component/Interface or fully qualified java class name.&lt;/p&gt;&lt;p&gt;It returns 'true' if&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The object passed is an instance of a component which is same as specified type or inherits it or implements the specified interface. Just to be clear, a component 'A' inherits a component 'B' if A or any of its super component extends 'B'. Similarly a Component 'A' implements an interface 'B' if A or any of its super component, implements interface 'B' or any of the interface that 'A' or its parents implement, extends from the specified interface.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The object passed is an instance of a java class (created using cfobject or createObject for java class) which is same as specified class name or inherits the specified class name or implements the specified interface.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here is an example&lt;/p&gt;Intf.cfc &lt;pre&gt;&lt;div class="code"&gt;&amp;lt;cfinterface&amp;gt;&lt;br /&gt;&amp;lt;cffunction name = "foo"&amp;gt;&lt;br /&gt;&amp;lt;/cffunction&amp;gt;&lt;br /&gt;&amp;lt;/cfinterface&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Comp.cfc&lt;/p&gt;&lt;pre&gt;&lt;div class="code"&gt;&amp;lt;cfcomponent implements="Intf"&amp;gt;&lt;br /&gt;&amp;lt;cffunction name = "foo"&amp;gt;&lt;br /&gt;   &amp;lt;cfoutput&amp;gt;In method foo&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&amp;lt;/cffunction&amp;gt;&lt;br /&gt;&amp;lt;/cfcomponent&amp;gt;&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;test.cfm&lt;/p&gt;&lt;pre&gt;&lt;div class="code"&gt;&lt;p&gt;&amp;lt;cfset obj = CreateObject("Component", "Comp")&amp;gt;&lt;br /&gt;&amp;lt;!--- Create a Java object ---&amp;gt;&lt;br /&gt;&amp;lt;cfset javaObj = CreateObject("java", "java.lang.StringBuffer")&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;object is of type Comp : #IsInstanceOf(obj, "Comp")#&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;object is of type Intf : #IsInstanceOf(obj, "Intf")#&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&lt;/p&gt;&amp;lt;cfoutput&amp;gt;java object is of type String : #IsInstanceOf(javaobj, "java.lang.String")#&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;java object is of type StringBuffer : #IsInstanceOf(javaobj, "java.lang.StringBuffer")#&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-9065885839121555236?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/9065885839121555236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=9065885839121555236' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/9065885839121555236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/9065885839121555236'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/08/coldfusion-8-isinstanceof.html' title='ColdFusion 8 : IsInstanceOf'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5786769702687105048</id><published>2007-08-01T04:46:00.001-07:00</published><updated>2007-08-01T04:46:14.967-07:00</updated><title type='text'>Printers harmful to health..</title><content type='html'>&lt;p&gt;I am not kidding. There was a recent study done&amp;nbsp;by Queensland University of Technology, Australia which said that printers are hazardous and can cause sever illness including cancer ! Check out the report &lt;a href="http://www.news.com.au/couriermail/story/0,23739,22165297-23272,00.html" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5786769702687105048?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5786769702687105048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5786769702687105048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5786769702687105048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5786769702687105048'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/08/printers-harmful-to-health.html' title='Printers harmful to health..'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-4189350120951066397</id><published>2007-08-01T03:58:00.001-07:00</published><updated>2007-08-01T04:30:55.308-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><title type='text'>ColdFusion 8 performance whitepaper</title><content type='html'>&lt;p&gt;&lt;/p&gt; &lt;p&gt;I am glad to see the ColdFusion community so excited with CF 8 performance. We got very encouraging response regarding the performance in our pre-release forums and we are thankful to everyone who gave such invaluable feedbacks. Though people started seeing a very good performance gain in their application on ColdFusion 8, we never talked about the performance benchmark numbers until &lt;a href="http://cfunited.com" target="_blank"&gt;CFUnited&lt;/a&gt; 2007, where &lt;a href="http://forta.com" target="_blank"&gt;Ben&lt;/a&gt; showed the &lt;a href="http://www.forta.com/blog/index.cfm/2007/6/27/ColdFusion-8-Performance-Numbers" target="_blank"&gt;performance numbers&lt;/a&gt; for ColdFusion 8.&amp;nbsp;No wonder&amp;nbsp;this&amp;nbsp;is the&amp;nbsp;#1reason in &lt;a href="http://www.adobe.com/devnet/coldfusion/articles/whatsnew_cf8.html" target="_blank"&gt;Top 8 reasons why you want ColdFusion 8&lt;/a&gt;&amp;nbsp;:-). &lt;/p&gt; &lt;p&gt;Extracting performance up to this extent was not an easy task. We analyzed nearly 2.4 million lines of real life CF application code,&amp;nbsp;to zero-in on the most commonly used tags and functions. Main challenge was after that - analyze the generated java code for all the tags, change the compiler to generate more optimized code, run it through profiler and optimize&amp;nbsp;CF engine for each of the tags and functions and their various combinations. And this went on and on in many many iterations. Overall it was real fun :-)&lt;/p&gt; &lt;p&gt;I still remember the most exciting moment when I ran the load test for CFC, after I had made some code changes, and the result was freaking unbelievable. It looked too good to be true and I was literally running around with the code changes to run it on other machines and verify it&amp;nbsp;. That one small change gave nearly 6x gain :-). It is not that the CF7 code was inefficient or poorly written. It was only matter of extracting juices as much as possible and putting some smart intelligence.&lt;/p&gt; &lt;p&gt;Check out the &lt;a href="http://www.adobe.com/products/coldfusion/pdfs/cf8_performancebrief.pdf" target="_blank"&gt;ColdFusion 8 performance whitepaper&lt;/a&gt;&amp;nbsp;which talks in much detail about the performance numbers for different areas, the methodology used for benchmarking etc. &lt;a href="http://manjukiranp.blogspot.com/" target="_blank"&gt;Manju Kiran&lt;/a&gt;,&amp;nbsp;who was my QA-buddy for most of the features I worked on, did a tremendous job in setting up and running the benchmark and creating the meat of this wonderful document (and of course keeping me on toes).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-4189350120951066397?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/4189350120951066397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=4189350120951066397' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4189350120951066397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4189350120951066397'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/08/coldfusion-8-performance-whitepaper.html' title='ColdFusion 8 performance whitepaper'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-6004221320991716267</id><published>2007-07-19T13:00:00.001-07:00</published><updated>2008-12-10T06:01:41.837-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='list'/><category scheme='http://www.blogger.com/atom/ns#' term='listToArray'/><title type='text'>ListToArray in ColdFusion 8</title><content type='html'>There has been lots and lots of discussion in CF blogs and forums about ListToArray not supporting empty elements. Seeing which I had &lt;a href="http://coldfused.blogspot.com/2007/06/listtoarray-with-empty-elements.html" target="_blank"&gt;blogged&lt;/a&gt; about a simple way which could do the same. Thanks to &lt;a href="http://cfblog.griefer.com/index.cfm/id/make_like_a_banana_and_split" target="_blank"&gt;Charlie Griefer&lt;/a&gt; for pointing out the problem in it and then thanks to &lt;a href="http://www.bennadel.com/blog/492-Caution-Java-String-Split-Does-Not-Create-A-ColdFusion-Array.htm" target="_blank"&gt;Ben Nadel&lt;/a&gt; and Andrew Clark for pointing me in the right direction. &lt;p&gt;Though it got pretty late, I was able to sneak-in this change in ColdFusion 8. ListToArray() now takes an additional optional argument "includeEmptyElements", which if 'true' will include the empty elements of list into the array. Default is of course 'false'. It also takes care of empty elements at the end of list and multiple delimiters. Here is how the function looks&lt;/p&gt; &lt;div class="code"&gt;ListToArray(list, delimiter, includeEmptyElements) returns Array&lt;/div&gt; &lt;p&gt;Lets take a look at couple of examples to see it working&lt;/p&gt; &lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfset list = "a,b,,c, ,d,,"&amp;gt;&lt;br /&gt;&amp;lt;cfset arr = ListToArray(list, ',', true)&amp;gt;&lt;br /&gt;&amp;lt;cfdump var="#arr#"&amp;gt;&lt;/pre&gt;&lt;/div&gt;Here is how the output looks.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_bIpyKqHMpHg/Rp_DXc1DBAI/AAAAAAAAAAs/qe3dWdftC7s/s1600-h/list2arr1.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 100pt; float: left; cursor: pointer;" src="http://2.bp.blogspot.com/_bIpyKqHMpHg/Rp_DXc1DBAI/AAAAAAAAAAs/qe3dWdftC7s/s320/list2arr1.JPG" alt="" id="BLOGGER_PHOTO_ID_5089000911595045890" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;Here is another example.&lt;br /&gt;&lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfset list = "one,/$/,six"&amp;gt;&lt;br /&gt;&amp;lt;cfset arr = listToArray(list, ",$/",true)&amp;gt;&lt;br /&gt;&amp;lt;cfdump var="#arr#"&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The output for which looks like this&lt;/p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_bIpyKqHMpHg/Rp_Dr81DBBI/AAAAAAAAAA0/0k_D-vOrVog/s1600-h/list2arr2.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 100pt; float: left; cursor: pointer;" src="http://4.bp.blogspot.com/_bIpyKqHMpHg/Rp_Dr81DBBI/AAAAAAAAAA0/0k_D-vOrVog/s320/list2arr2.JPG" alt="" id="BLOGGER_PHOTO_ID_5089001263782364178" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Though we wanted to, there was just not enough time to make similar change in all the list functions for CF 8. Something for CF 9 :-)&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-6004221320991716267?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/6004221320991716267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=6004221320991716267' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6004221320991716267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6004221320991716267'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/07/listtoarray-in-coldfusion-8.html' title='ListToArray in ColdFusion 8'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_bIpyKqHMpHg/Rp_DXc1DBAI/AAAAAAAAAAs/qe3dWdftC7s/s72-c/list2arr1.JPG' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5206884911195051443</id><published>2007-07-19T04:51:00.001-07:00</published><updated>2007-07-19T04:59:15.817-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Enhancements to CFDocument in ColdFusion 8</title><content type='html'>&lt;p&gt;As you all know, CFDocument tag is used to easily create pdf or flashpaper documents from HTML/CFML content. ColdFusion 8 has added lot of enhancements to it and in this post we will talk about those enhancements.  &lt;/p&gt;&lt;p&gt;1. &lt;strong&gt;Bookmark&lt;/strong&gt; : You can create bookmarks for each section of the pdf using "bookmark" attribute. The bookmark created is of only one level and its name is set to the documentsection's name. Here is a sample code for creating pdf with bookmarks.  &lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfdocument format="PDF" bookmark="yes"&amp;gt;&lt;br /&gt;   &amp;lt;cfdocumentsection name="Introduction"&amp;gt;&lt;br /&gt;       &amp;lt;h3&amp;gt;Introduction&amp;lt;/h3&amp;gt;&lt;br /&gt;       &amp;lt;p&amp;gt;The introduction goes here.&amp;lt;/p&amp;gt;&lt;br /&gt;   &amp;lt;/cfdocumentsection&amp;gt;&lt;br /&gt;   &amp;lt;cfdocumentsection name="Chapter 1"&amp;gt;&lt;br /&gt;       &amp;lt;h3&amp;gt;Chapter 1: Getting Started&amp;lt;/h3&amp;gt;&lt;br /&gt;       &amp;lt;p&amp;gt;Chapter 1 goes here.&amp;lt;/p&amp;gt;&lt;br /&gt;   &amp;lt;/cfdocumentsection&amp;gt;&lt;br /&gt;   &amp;lt;cfdocumentsection name="Chapter 2"&amp;gt;&lt;br /&gt;       &amp;lt;h3&amp;gt;Chapter 2: Building Applications&amp;lt;/h3&amp;gt;&lt;br /&gt;       &amp;lt;p&amp;gt;Chapter 2 goes here.&amp;lt;/p&amp;gt;&lt;br /&gt;   &amp;lt;/cfdocumentsection&amp;gt;&lt;br /&gt;   &amp;lt;cfdocumentsection name="Conclusion"&amp;gt;&lt;br /&gt;       &amp;lt;h3&amp;gt;Conclusion&amp;lt;/h3&amp;gt;&lt;br /&gt;       &amp;lt;p&amp;gt;The conclusion goes here.&amp;lt;/p&amp;gt;&lt;br /&gt;   &amp;lt;/cfdocumentsection&amp;gt;&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;2. &lt;strong&gt;Proxy Support&lt;/strong&gt; : With ColdFusion 8, you can now provide proxy configuration to cfdocument for retrieving external content like images. This will be useful in situation where the machine hosting ColdFusion is connected to the external world via a proxy. The new attributes added for this (which are self explanatory) are listed below&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;proxyHost&lt;br /&gt;&lt;/li&gt;&lt;li&gt;proxyPort&lt;br /&gt;&lt;/li&gt;&lt;li&gt;proxyUser&lt;br /&gt;&lt;/li&gt;&lt;li&gt;proxyPort &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;3. &lt;strong&gt;Content from URL : &lt;/strong&gt;Though this was added in 7.0.2, I think it makes sense to add here because it was not there in 7. :-) Have you ever created or wanted to create a pdf from a web page? If yes, then the new attribute "&lt;strong&gt;src&lt;/strong&gt;" in cfdocument and cfdocumentsection tag makes it very easy to do this. Here is an example to do this.&lt;br /&gt;&lt;/p&gt;&lt;div class="code"&gt;&amp;lt;cfdocument format="pdf" &lt;strong&gt;src&lt;/strong&gt;="http://www.google.com" /&amp;gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt; 4. &lt;strong&gt;Basic Authentication&lt;/strong&gt; : If the CFDocument body contains a resource (e.g; image or URL) that is protected with basic authentication, ColdFusion 7 can not retrieve it and it was one of the reason for getting "red-x" for images. (See &lt;a href="http://coldfused.blogspot.com/2005/11/missing-images-in-cfdocument.html"&gt;my old post&lt;/a&gt; on this). ColdFusion 8 addresses this by adding these two attributes to cfdocument and cfdocumentsection tag.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;authuser - user name to be used for basic authentication.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;authpassword - password to be used for basic authentication.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;5. &lt;strong&gt;User Agent : &lt;/strong&gt;There are some cases where the web server is configured to allow requests only from a certain set of browsers (User agents to be precise) to prevent spiders and bots from overloading the server. In ColdFusion 7, when CFDocument creates a URLConnection for an image, it sends a "User-Agent" header, that looks like "User-Agent:Java/1.4.2_07", in the HTTP request. If the web server does not recognize "Java" user-agent, it returns a status code of 404 (resource not found) and hence the images can not be displayed. ColdFusion 8 adds a new attribute "user-agent" to address this.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;user-agent : User agent to be used for making http connection. The default value will now be "ColdFusion". If this also does not work, you can use the same string that browsers like IE or firefox use. This attribute has been added to &amp;lt;cfdocument&amp;gt; and &amp;lt;cfdocumentsection&amp;gt; tag.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;6. &lt;strong&gt;PDF name&lt;/strong&gt; : When a pdf generated by cfdocument is sent to the browser and you try to save it, the browser will prompt with the cfm name for the pdf which is generally not desirable.  With ColdFusion 8, you can provide the appropriate name in "saveAsName" attribute of cfdocument.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;saveAsName - Name that appears in the 'saveAs' dialog when you try to save the pdf from the browser (Generally File -&amp;gt; saveAs). This name will not work if you use "save" dialog of the pdf plugin.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Here is a sample code for the same.&lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfdocument format="pdf" saveAsName="mypdf"&amp;gt;&lt;br /&gt; &amp;lt;p&amp;gt;This is a PDF document.&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;7. &lt;strong&gt;Local URLs : &lt;/strong&gt;When CFDocument body contains a relative URL, ColdFusion will resolve the relative URL to an absolute URL and will send an HTTP request for this url. A side effect of this is - Server ends up sending HTTP request even for local URL or images that are lying on the local file system which obviously hurts the performance. In ColdFusion 8, we have added a new attribute "localURL" to cfdocument tag which if enabled, will try to resolve the relative URLs as file on the local machine.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;localURL : "true" | "false" - It should be enabled if the images used in cfdocument body are on the local machine. This would make the cfdocument engine retrieve the images directly from the file system rather then asking the server for it over http. &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;This attribute helps reducing the load from the server so that the same web server thread can now serve user request instead of serving local images to CFDocument. This also addresses some of the "missing image" problems which I mentioned &lt;a href="http://coldfused.blogspot.com/2006/09/workaround-for-cfdocument-missing_19.html" target="_blank"&gt;here&lt;/a&gt;. Here is a sample code using this attribute.&lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfdocument format="PDF" localUrl="true"&amp;gt;&lt;br /&gt; &amp;lt;table&amp;gt;&lt;br /&gt;  &amp;lt;tr&amp;gt;&lt;br /&gt;     &amp;lt;td&amp;gt;bird&amp;lt;/td&amp;gt;&lt;br /&gt;     &amp;lt;td&amp;gt;&amp;lt;image src="images/bird.jpg"&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;/tr&amp;gt;&lt;br /&gt;  &amp;lt;tr&amp;gt;&lt;br /&gt;     &amp;lt;td&amp;gt;Rose&amp;lt;/td&amp;gt;&lt;br /&gt;     &amp;lt;td&amp;gt;&amp;lt;image src="images/rose.jpg"&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;/tr&amp;gt;&lt;br /&gt; &amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;8. &lt;strong&gt;Section Page Counts : &lt;/strong&gt;CFDOCUMENT scope contains two new variables which give you the page counts for document section.&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;TOTALSECTIONPAGECOUNT - total no of pages in the current section&lt;br /&gt;&lt;/li&gt;&lt;li&gt;CURRENTSECTIONPAGENUMBER - Current page number in the current section.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;9. &lt;strong&gt;Dynamic header and footer : &lt;/strong&gt;CFDOCUMENT scope variables can now be used in expressions inside &amp;lt;cfdocumentitem&amp;gt; which makes it possible to have dynamic header and footers. You can now build logic for header/footer content based on the page number. Here is a sample code which prints section title if the page is even and prints the page no otherwise. Below is a code snippet which creates a dynamic header.&lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;    &amp;lt;cfdocumentitem type="header"&amp;gt;&lt;br /&gt;       &amp;lt;cfif (cfdocument.currentpagenumber mod 2) is 0&amp;gt;&lt;br /&gt;           &amp;lt;cfoutput&amp;gt;#sectionTitle#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;       &amp;lt;cfelse&amp;gt;&lt;br /&gt;           &amp;lt;cfoutput&amp;gt;#cfdocument.currentpagenumber# of #cfdocument.TOTALPAGECOUNT#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;        &amp;lt;/cfif&amp;gt;&lt;br /&gt;   &amp;lt;/cfdocumentitem&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;10. We have also fixed most of the CFDocument related bugs e.g text chopping, image cropping or red-x, image scaling, "Document has no pages" etc.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5206884911195051443?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5206884911195051443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5206884911195051443' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5206884911195051443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5206884911195051443'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/07/enhancements-to-cfdocument-in.html' title='Enhancements to CFDocument in ColdFusion 8'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3621068923510990584</id><published>2007-07-17T09:22:00.000-07:00</published><updated>2007-07-17T09:27:50.095-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='file'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><title type='text'>New File I/O in ColdFusion 8 - Part II</title><content type='html'>In my &lt;a href="http://coldfused.blogspot.com/2007/07/new-file-io-in-coldfusion-8.html"&gt;previous post&lt;/a&gt; I talked about how new file I/O functions address working with large files. In this post I will talk about other file functions that have been added in ColdFusion 8. Most of these functions are equivalent to the cffile operations and we have retained the same behaviour as cffile. A side effect of that is - relative paths used in these functions are relative to the temp directory. I don't really like that and I believe that it should have been relative to the template. But since these functions were supposed to replicate cffile behaviour, we had to live with it. :-)&lt;br /&gt;&lt;br /&gt;Here we go with the list of those new functions&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FileRead(filepath, [charset])&lt;/span&gt; - Similar to cffile, this function reads the entire content of a text file and returns the read content. you can also opitonally pass the charset to be used to read the text file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FileReadBinary(filepath)&lt;/span&gt; - This reads the entire content of a binary file and returns the byte array.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FileWrite(filepath, textdata | binarydata, [charset])&lt;/span&gt; - Writes the specified content to the file. The content can be binary as well as text. If the specified content is a text data, you can optionally specify the charset so that the data can be written properly to the file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FileCopy(source, destination)&lt;/span&gt; - As the name suggests, it copies the source file to destination file. Similar to cffile, if the destination is a directory, then source will be copied to that directory otherwise source file will be copied to the destination file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FileMove(source, destination)&lt;/span&gt; - Moves the file from source to destination. Here again, if the destination is a directory, then source is moved under destination directory. Otherwise source is renamed to the destination.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FileDelete(filepath)&lt;/span&gt; - Deletes the specified file. The only important thing to note here is that if the file is readOnly, it will not be deleted.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FileSetAttribute(filepath, attribute)&lt;/span&gt; - Sets the attributes on file. Applies to Windows. 'attribute' here is a comma-delimited list of attributes to set on the file. Possible attribute values are "readOnly" | "hidden" | "normal".&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;FileSetAccessMode(filepath, mode)&lt;/span&gt; - Sets the file access mode for Unix or Linux systems where the mode is octal values of UNIX chmod command assigned to owner, group, and other, respectively. To give full permission to everyone for a file, the mode should be 777.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;GetFileInfo(filepath)&lt;/b&gt; - So far till ColdFusion 7, there was no good way to find information like size, last modified date etc about a file. Only way you could do that was to use cfdirectory tag to list the directory, get the query from it, loop over the query until you hit the desired file and then fetch the required metadata. The new function GetFileInfo in ColdFusion 8 provides an easy way to get all the meta-data about a file or directory. This returns a struct which is described below.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;name&lt;/b&gt; - Name of the file/directory specified. This is just the file name and not the absolute path.&lt;/li&gt;&lt;li&gt;&lt;b&gt;path&lt;/b&gt; - Full path of the file/directory.&lt;/li&gt;&lt;li&gt;&lt;b&gt;parent&lt;/b&gt; - Full path of the parent directory.&lt;/li&gt;&lt;li&gt;&lt;b&gt;type&lt;/b&gt; - "directory" if the filepath is a directory else "file".&lt;/li&gt;&lt;li&gt;&lt;b&gt;size&lt;/b&gt; - size of the file in bytes.&lt;/li&gt;&lt;li&gt;&lt;b&gt;lastmodified&lt;/b&gt; - DateTime at which this file/directory was last modified.&lt;/li&gt;&lt;li&gt;&lt;b&gt;canRead&lt;/b&gt; - "true" if this file/directory has 'read' permission.  "false" Otherwise.&lt;/li&gt;&lt;li&gt;&lt;b&gt;canWrite&lt;/b&gt; - "true" if this file/directory has 'write' permission. "false" Otherwise.&lt;/li&gt;&lt;li&gt;&lt;b&gt;isHidden&lt;/b&gt; - "true" if this file/directory is hidden. "false" Otherwise.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3621068923510990584?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3621068923510990584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3621068923510990584' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3621068923510990584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3621068923510990584'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/07/new-file-io-in-coldfusion-8-part-ii.html' title='New File I/O in ColdFusion 8 - Part II'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-2889576331698583726</id><published>2007-07-11T13:49:00.000-07:00</published><updated>2008-12-10T06:01:42.067-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='file'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><title type='text'>Few more details on File handle</title><content type='html'>In my &lt;a href="http://coldfused.blogspot.com/2007/07/new-file-io-in-coldfusion-8.html"&gt;previous post&lt;/a&gt; I talked about file object that you get on FileOpen() which is nothing but handle to the native file. Did you ever try to dump this object? This file object provides lot of valuable information. If I run this code below&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset myfile = FileOpen("C:\cfunited_notes.txt")&amp;gt;&lt;br /&gt;&amp;lt;cfdump var="#myfile#"&amp;gt;&lt;br /&gt;&amp;lt;cfloop condition="Not FileIsEOF(myfile)"&amp;gt;&lt;br /&gt;    &amp;lt;cfset line = FileReadLine(myfile)&amp;gt;&lt;br /&gt;    &amp;lt;cfoutput&amp;gt;#line#&amp;lt;/cfoutput&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&amp;lt;cfset FileClose(myfile)&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;this is what gets dumped.&lt;br /&gt;&lt;br /&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://3.bp.blogspot.com/_bIpyKqHMpHg/RpVHj8yYxYI/AAAAAAAAAAU/JBHSGX0uJNU/s320/filedump.jpg" alt="" id="BLOGGER_PHOTO_ID_5086050037123302786" border="0" /&gt;As you can see, it gives you information like lastmodified time, mode in which the file was opened, name, path, size in bytes and status of this file object whether this is still open or closed.&lt;br /&gt;&lt;br /&gt;This object acts very much like a struct. So you can access these data from the file object using the simple dot notation. For example, to find out the last modified time, you can use fileObj.lastmodified&lt;br /&gt;&lt;br /&gt;That gives another useful tool in your hand. While you are writing a file incrementally, you can easily find out the size of the file written so far using fileObj.size. This will be very helpful if you want to build a logging application where log files are rotated. While you are logging the data, as soon as the file size becomes more than your certain limit, you can close the file object and start writing to a new log file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-2889576331698583726?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/2889576331698583726/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=2889576331698583726' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/2889576331698583726'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/2889576331698583726'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/07/few-more-details-on-file-handle.html' title='Few more details on File handle'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_bIpyKqHMpHg/RpVHj8yYxYI/AAAAAAAAAAU/JBHSGX0uJNU/s72-c/filedump.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-431948704999363339</id><published>2007-07-10T12:35:00.000-07:00</published><updated>2007-07-10T13:14:12.901-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='cfloop'/><category scheme='http://www.blogger.com/atom/ns#' term='file'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>New File I/O in ColdFusion 8</title><content type='html'>Till now we have been using  &lt;span style="font-family:courier new;"&gt;&amp;lt;cffile&amp;gt; &lt;/span&gt; for all kind of file operations and it does a very good job. If you want to read a file, give the file to this tag and this tag gives you the read content. If you want to write content to a file, you give the content and file name to this tag and it will do that. You want to copy/delete/move your files, this tag will do all of that. All very simple and short. But there are two particular issues which &amp;lt;&lt;span style="font-family:courier new;"&gt;cffile&lt;/span&gt;&amp;gt; does not address.&lt;br /&gt;&lt;p&gt;1. Reading/writing big files - Since &lt;span style="font-family:courier new;"&gt;&amp;lt;cffile&amp;gt;&lt;/span&gt; is a tag, it can only perform one-shot operations. So, to read, it has to read everything in one shot and to write, you have to provide the entire content and that means that &lt;span style="font-family:courier new;"&gt;&amp;lt;cffile&amp;gt; &lt;/span&gt;will have to keep the entire content in memory. It  is not of much concern if the file size is just few KBs but as the size increases beyond 100 kb or when it reaches few megs, it can really hurt. It would create a memory crunch on the server and if the load is high and there are many read/write happening simultaneously with large files, it can even lead to OutOfMemory error in server. Apart from creating memory crunch, it will also slow down the server because VM would need to allocate/deallocate larger chunk of memory which would lead to larger and frequent Garbage Collection cycle. At this point, you might ask, why would I ever read or write such a big file? Well I can think of few&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You need to process the data that comes in a flat file&lt;/li&gt;&lt;li&gt;csv parsing&lt;/li&gt;&lt;li&gt;Finding the mime type of a file like mp3, image, video etc&lt;/li&gt;&lt;li&gt;you want to create a log viewer&lt;/li&gt;&lt;li&gt;... many more&lt;/li&gt;&lt;/ul&gt;You get the idea.. right?&lt;br /&gt;&lt;br /&gt;2. Again since &lt;span style="font-family:courier new;"&gt;&amp;lt;cffile&amp;gt; &lt;/span&gt;is a tag, it is not very easy to use inside cfscript. Either you have to move out of cfscript to use this tag or you wrap this tag in a function and call that function. Though thats true with all the tags but cffile is so commonly used that this looks like a limitation.&lt;br /&gt;&lt;br /&gt;New File I/O introduced in ColdFusion 8 addresses both these problems. New File I/O is all based on functions and hence that automatically takes care of problem 2. That means you no longer need to use cffile if you are inside cfscript. I will give more details on handling problem 2 in my next post. In this post I will mainly focus on reading/writing files in chunk using new IO .&lt;br /&gt;&lt;p&gt;The new I/O is based on the same philosophy that is used in other languages i.e;&lt;br /&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;You first open a file&lt;/li&gt;&lt;li&gt;Perform read/write operations on it&lt;/li&gt;&lt;li&gt;and close the file.&lt;/li&gt;&lt;/ol&gt;Lets see each of the steps in little detail.&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Step 1&lt;/b&gt;&lt;/span&gt; : Open a file : Here is the function to open a file&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;FileOpen(filepath [,mode] [,charset]) -&gt; fileobject&lt;/pre&gt;Both mode and charset here and optional. Mode can be "read", "readBinary", "write" or "append"&lt;br /&gt;&lt;p&gt;"&lt;span style="font-style: italic;"&gt;read&lt;/span&gt;" mode, which is default, is used to read a text file and hence any read operation will give you text data from it. When the file is a text file, you can also optionally specify the charset of the file. So if the file contains UTF-8 or UTF-16 characters (or characters from any other charset), you need to specify it while opening the file.&lt;br /&gt;&lt;br /&gt;"&lt;span style="font-style: italic;"&gt;readBinary&lt;/span&gt;" is used to read a binary file and hence any read operation will give you the binary data i.e byte array.&lt;br /&gt;&lt;br /&gt;"&lt;span style="font-style: italic;"&gt;write&lt;/span&gt;" mode will open the file in write mode which means that if the file already exists, it will be overwritten.&lt;br /&gt;&lt;br /&gt;"&lt;span style="font-style: italic;"&gt;append&lt;/span&gt;" mode, as the name suggests, will open the file in append mode which means that any write operation on that file object will write it at the end of file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;FileOpen &lt;/span&gt;function returns you a handle to the native file and you need to use this handle for all further read/write operation. Of course you should keep in mind that you can not perform "read" operation on a file handle that was opened in "write" mode and vice versa.&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Step 2&lt;/span&gt;&lt;/b&gt; : Do Read/Write operations : Once you get the handle to file object, you can perform &lt;b&gt;multiple read/write&lt;/b&gt; operations using this handle. There are several functions to do that.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2A. Read Operation&lt;/b&gt; :&lt;br /&gt;&lt;br /&gt;i) &lt;span style="font-family:courier new;"&gt;FileRead(fileobj, no of character/bytes to read) &lt;/span&gt;: This provides you a way to read a chunk of data (say 1 kb at a time) from the file at a time. Since you only read a chink of data at a time, it does not create memory crunch on the server. Since this is read operation, file must have been opened in "read" or "readBinary" mode. Depending on which mode the file was opened, this function will return the text or binary data read. One thing to note here - If the data remaining is less than the requested size, this method will return you only the remainign data. i.e if 100 character are remaining in the file being read, and you request for 1000 characters, it will return you 100 characters only.&lt;br /&gt;&lt;br /&gt;ii) &lt;span style="font-family:courier new;"&gt;FileReadLine(fileobject)&lt;/span&gt; - This reads one line from the text file. To call this method, the file must have been opened in "read" mode.&lt;br /&gt;&lt;br /&gt;Both these read operations can be called multiple times until you reach end of the file. One the end of file has reached, any further read call will result into an "EndOfFile" error. So in order to avoid this error, you should always check whether you have reached the end of file. And the function to do that is&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;FileIsEOF(fileobj)&lt;/span&gt; : Just to be more clear, EOF here stands for "End of File". This function will return true if the end of file has been reached otherwise will return false.&lt;br /&gt;&lt;br /&gt;Here are few examples of reading content from file&lt;br /&gt;Read 1 kb binary data at a time.&lt;br /&gt;&lt;/p&gt;&lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;    myfile = FileOpen("c:\temp\song.mp3", "readbinary");&lt;br /&gt;    while (! FileIsEOF(myfile)) { // continue the loop if the end of file has not reached&lt;br /&gt;       x = FileRead(myfile, 1024); // read 1 kb binary data&lt;br /&gt;       ...// process this binary data..&lt;br /&gt;    }&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Process a text file line by line&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;    myfile = FileOpen("c:\temp\myfile.txt", "read");&lt;br /&gt;    while (! FileIsEOF(myfile)) { // continue the loop if the end of file has not reached&lt;br /&gt;        x = FileReadLine(myfile); // read a line&lt;br /&gt;        ...// process this line..&lt;br /&gt;    }&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;b&gt;2B. Write operation&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;i)FileWrite(fileobject, content) - This will add the text or binary content to the file. The file must have been opened in "write" or "append" mode.&lt;br /&gt;&lt;br /&gt;ii) FileWriteLine(fileobject, text) - This will add the text followed by a new line character to the file. Here again, the file must have been opened in "write" or "append" mode.&lt;br /&gt;&lt;br /&gt;You might wonder that if both the write operations add the content to the file, whats the difference between "write" and "append" mode? The difference is only at the time of opening the file. As I said earlier, opening the file in "write" mode will overwrite the file if already existsed and put the file pointer at the the beginning of file. Whereas opening file in "append" mode will simply put the file pointer at the end of file.&lt;br /&gt;&lt;br /&gt;Any subsequent "write" calls, irrespective of "write" or "append" mode, will append the content to the file.&lt;br /&gt;&lt;br /&gt;Here is an example of writing content to a file. This reads one line from an input file, does some processing on it, and writes the resultant data to another file.&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;    infile = FileOpen("c:\temp\input.txt", "read");&lt;br /&gt;    outfile = FileOpen("C:\temp\result.txt", "write");&lt;br /&gt;    while (! FileIsEOF(infile)) { // continue the loop if the end of file has not reached&lt;br /&gt;        x = FileReadLine(infile); // read a line&lt;br /&gt;        data = processLine(x);&lt;br /&gt;        FileWriteLine(outfile, data);&lt;br /&gt;    }&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;b&gt;Step 3&lt;/b&gt;&lt;/span&gt; : Close the file : Once you are done with read/write operations, you *must* close the handle to file. And the way to do that is using function&lt;br /&gt;&lt;pre&gt;FileClose(fileobj)&lt;/pre&gt;What if you don't close the file object? Well, that file will remain locked by the server as long as the file is open, and no other process can modify/rename or delete that file.&lt;br /&gt;You might also ask, why does not ColdFusion automatically take care of closing the file? Why should the developer be bothered about it? Well.. ColdFusion does take care of it when the file object goes out of scope and if it is not kept in any accessible scopes but you can never be certain when exactly this will happen. This might happen immediately or this might happen hours later :-).&lt;br /&gt;Bottomline, you should make it a practice to call FileClose() once you are done with the file object.&lt;br /&gt;Just to show its usage, I will complete the example I used in write.&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;    infile = FileOpen("c:\temp\input.txt", "read");&lt;br /&gt;    outfile = FileOpen("C:\temp\result.txt", "write");&lt;br /&gt;    while (! FileIsEOF(infile)) { // continue the loop if the end of file has not reached&lt;br /&gt;        x = FileReadLine(infile); // read a line&lt;br /&gt;        data = processLine(x);&lt;br /&gt;        FileWriteLine(outfile, data);&lt;br /&gt;    }&lt;br /&gt;    FileClose(infile);&lt;br /&gt;    FileClose(outfile);&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;These set of functions would greatly help if you need to work with a file of more than 10 kb size.&lt;br /&gt;&lt;br /&gt;Apart from these set of functions, ColdFusion 8 also adds a new language struct to read text files. With ColdFusion 8, you can use &lt;span style="font-weight: bold;font-family:courier new;" &gt;&amp;lt;cfloop&amp;gt;&lt;/span&gt; to iterate over "lines" or "characters" in a text file. This makes it very easy and convenient to do any kind of text file parsing or processing in your application. Lets take a look at the new syntax of cfloop for reading file (and I really love this syntax :-)).&lt;br /&gt;&lt;p&gt;New attributes in cfloop for reading file :&lt;br /&gt;&lt;br /&gt;"&lt;span style="font-style: italic;"&gt;file&lt;/span&gt;" - path of the file to read&lt;br /&gt;"&lt;span style="font-style: italic;"&gt;characters&lt;/span&gt;" - no of characters to read in one iteration.&lt;br /&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Reading Lines&lt;/span&gt; : Below is the simplest syntax to read one line at a time from the file in a loop. This would read the entire file and the loop would end when the file has been completely read. The read content will be available in the index variable specified.&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfloop file="c:\temp\myfile.txt" index="line"&amp;gt;&lt;br /&gt;    &amp;lt;cfoutput&amp;gt;#line#&amp;lt;/cfoutput&amp;gt; &amp;lt;!--- or do whatever with the line ---&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;With cfloop, you can also iterate over a part of the file by specifying "from" and "to" values.&lt;br /&gt;Here is an example to loop over lines between 10 and 20.&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfloop file="c:\temp\myfile.txt" index="line" from=10 to=20&amp;gt;&lt;br /&gt;    &amp;lt;cfoutput&amp;gt;#line#&amp;lt;/cfoutput&amp;gt; &amp;lt;!--- or do whatever with the line ---&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;"from" and "to" both are optional attributes where "from" defaults to '1' i.e start of file and "to" defaults to the last line of the file.&lt;br /&gt;&lt;br /&gt;So to read first 10 lines from the file, you can use&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfloop file="c:\temp\myfile.txt" index="line" to="10"&amp;gt;&lt;br /&gt;    &amp;lt;cfoutput&amp;gt;#line#&amp;lt;/cfoutput&amp;gt; &amp;lt;!--- or do whatever with the line ---&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;One word of caution here - If you use "to" attribute here, its value must be less than the number of lines in the file otherwise you would get an "EndOfFile" error. For example, if I had only 5 lines in my file and value of to is 7, this would throw an error because line 6 and 7 do not exist.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Reading characters&lt;/span&gt; : For reading characters instead of line, you need to provide the value for "characters" attribute and as many characters will be read in one iteration. The loop will automatically end when the end of file has reached. The read content will be available in the index variable specified.&lt;br /&gt;&lt;br /&gt;An example for that is&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfloop file="c:\temp\myfile.txt" index="chars" characters="1000"&amp;gt;&lt;br /&gt;    &amp;lt;cfset x=chars&amp;gt;&lt;br /&gt;    &amp;lt;!--- do whatever with the characters ---&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;One important thing to note here. In the last iteration, when the end of file has reached, index variable will only have the remaining characters. For example if I have 130 characters in the file and I run the loop to read a chunk of 20 characters, in the last iteration, index variable's value will only have last 10 characters.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;This completes the first part of new File IO which mainly addresses the problem of working with larger files. However this does not mean that you can not or should not use these for smaller files. You can very much use these for all kind of files. These are very simple to use and perform really well. Go ahead and play around with it !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-431948704999363339?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/431948704999363339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=431948704999363339' title='20 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/431948704999363339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/431948704999363339'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/07/new-file-io-in-coldfusion-8.html' title='New File I/O in ColdFusion 8'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>20</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-6895512399398221972</id><published>2007-07-05T13:37:00.000-07:00</published><updated>2007-07-05T14:57:13.622-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><category scheme='http://www.blogger.com/atom/ns#' term='CFUnited'/><title type='text'>CFUnited '07 experience</title><content type='html'>This was my first CFUnited conference and I was amazed with the energy and passion of ColdFusion community. I have been to other non-CF conferences earlier and I can say that I had never seen such passionate and loyal developer community. The interaction that I had with folks there was really awesome and much valuable. The excitement and buzz around ColdFusion 8 was tremendous and all of us in the team are really excited with the response. I am sure ColdFusion 8 will be the best ColdFusion release so far. &lt;br /&gt;&lt;br /&gt;All the sessions around CF8 including my session on "CFML Enhancements in ColdFusion 8" were full packed sessions and were very well received. Thanks a lot guys if you attended my session :-). &lt;a href="http://www.rupeshk.org/preso/CFUnited_Language_enhancement.pdf"&gt;Here are the slides&lt;/a&gt; for my session in case you missed it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-6895512399398221972?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/6895512399398221972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=6895512399398221972' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6895512399398221972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6895512399398221972'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/07/cfunited-07-experience.html' title='CFUnited &apos;07 experience'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3512352049281584757</id><published>2007-06-26T03:41:00.000-07:00</published><updated>2007-06-26T04:03:28.629-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='CFUnited'/><title type='text'>At CFunited 07</title><content type='html'>I am posting this from Bethesda Marriott where I am attending &lt;a href="http://cfunited.com/"&gt;CFUnited&lt;/a&gt;. I would love to  meet you guys if you are here. You can catch me near our booth or at the end of my session where I will be speaking on "Language Enhancements in ColdFusion 8" on Thursday morning 8.30 - 9.30. Apart from tons of feature, we have done lots and lots of enhancements in Scorpio which should help you write better and faster application. I have selected some of the exciting enhancements for this session which I am sure you would love.&lt;br /&gt;See you there !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3512352049281584757?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3512352049281584757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3512352049281584757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3512352049281584757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3512352049281584757'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/06/at-cfunited-07.html' title='At CFunited 07'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8709427147995744264</id><published>2007-06-18T09:44:00.000-07:00</published><updated>2007-06-18T10:02:31.821-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><title type='text'>New CFDocument hotfix released !</title><content type='html'>We have released &lt;a href="http://www.adobe.com/go/kb402093"&gt;ColdFusion MX 7.02 - CFDocument Cumulative Hot Fix&lt;/a&gt; that fixes lot of CFDocument related issues.&lt;br /&gt;Some of the important issues that we fixed in this hotfix are&lt;br /&gt;&lt;br /&gt;1. Text getting chopped / clipped&lt;br /&gt;2. Image zoom or image cropped&lt;br /&gt;3. Header/Footer overwriting the text in the page body.&lt;br /&gt;&lt;br /&gt;If you use cfdocument, it is a must have hotfix for you.&lt;br /&gt;&lt;br /&gt;You can download the hotfix &lt;a href="http://kb.adobe.com/support/coldfusion/ts/documents/kb402093/hf702-65719.zip"&gt;here&lt;/a&gt; but do not forget to read the instructions to apply this hotfix. Enjoy !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8709427147995744264?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8709427147995744264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8709427147995744264' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8709427147995744264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8709427147995744264'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/06/new-cfdocument-hotfix-released.html' title='New CFDocument hotfix released !'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3864918656657081085</id><published>2007-06-08T15:22:00.000-07:00</published><updated>2007-06-08T15:59:44.149-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Finding Image Type for a file</title><content type='html'>This is a follow up on my previous post on &lt;a href="http://coldfused.blogspot.com/2007/06/finding-mime-type-of-any-file.html"&gt;URLConnection APIs&lt;/a&gt;&lt;br /&gt;We will use this API to find out the image type of a given file. Here is the udf.&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cffunction name="getMimeType"&amp;gt;&lt;br /&gt;    &amp;lt;cfargument name="filepath"&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;cfset var urlConn = createObject("java", "java.net.URLConnection")&amp;gt;&lt;br /&gt;    &amp;lt;cfset var fileobj = fileopen(filepath, "readbinary")&amp;gt;&lt;br /&gt;    &amp;lt;!--- just read the first 20 characters of the file as thats sufficient ---&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;cfset var bytes = fileread(fileobj, 20)&amp;gt;&lt;br /&gt;    &amp;lt;cfset var istream = createObject("java", "java.io.ByteArrayInputStream").init(bytes)&amp;gt;&lt;br /&gt;    &amp;lt;cfset fileobj.close()&amp;gt;&lt;br /&gt;    &amp;lt;cfreturn urlConn.guessContentTypeFromStream(istream)&amp;gt;&lt;br /&gt;&amp;lt;/cffunction&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cffunction name="GetImageType"&amp;gt;&lt;br /&gt;    &amp;lt;cfargument name="filepath"&amp;gt;&lt;br /&gt;    &amp;lt;cfset var mimetype = getMimeType(filepath)&amp;gt;&lt;br /&gt;    &amp;lt;cfset var imagetype=""&amp;gt;&lt;br /&gt;    &amp;lt;cfif not isDefined("mimetype")&amp;gt;&lt;br /&gt;        &amp;lt;cfthrow message="Not an Image file"&amp;gt;&lt;br /&gt;    &amp;lt;/cfif&amp;gt;&lt;br /&gt;    &amp;lt;cfswitch expression="#mimetype#"&amp;gt;&lt;br /&gt;        &amp;lt;cfcase Value="image/gif"&amp;gt;&lt;br /&gt;            &amp;lt;cfset imagetype="gif"&amp;gt;&lt;br /&gt;        &amp;lt;/cfcase&amp;gt;&lt;br /&gt;        &amp;lt;cfcase Value="image/x-bitmap"&amp;gt;&lt;br /&gt;            &amp;lt;cfset imagetype="bmp"&amp;gt;&lt;br /&gt;        &amp;lt;/cfcase&amp;gt;&lt;br /&gt;        &amp;lt;cfcase Value="image/png"&amp;gt;&lt;br /&gt;            &amp;lt;cfset imagetype="png"&amp;gt;&lt;br /&gt;        &amp;lt;/cfcase&amp;gt;&lt;br /&gt;        &amp;lt;cfcase Value="image/jpeg"&amp;gt;&lt;br /&gt;            &amp;lt;cfset imagetype="jpeg"&amp;gt;&lt;br /&gt;        &amp;lt;/cfcase&amp;gt;&lt;br /&gt;        &amp;lt;cfcase Value="image/jpg"&amp;gt;&lt;br /&gt;            &amp;lt;cfset imagetype="jpeg"&amp;gt;&lt;br /&gt;        &amp;lt;/cfcase&amp;gt;&lt;br /&gt;        &amp;lt;cfdefaultcase&amp;gt;&lt;br /&gt;            &amp;lt;cfthrow message="Not an Image file"&amp;gt;&lt;br /&gt;        &amp;lt;/cfdefaultcase&amp;gt;&lt;br /&gt;    &amp;lt;/cfswitch&amp;gt;&lt;br /&gt;    &amp;lt;cfreturn imagetype&amp;gt;&lt;br /&gt;&amp;lt;/cffunction&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;If I run the code below&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset filepath = "C:\temp\test.jpg"&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;#GetImageType(filepath)#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;It nicely prints out "jpeg". &lt;p&gt;&lt;br /&gt;&lt;br /&gt;You should note that I used the new File IO function added in ColdFusion 8 using which I can read as many no of bytes from the file as I want. No more reading the entire file into memory. &lt;br&gt;&lt;br /&gt;More extensive post on File IO functions coming next !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3864918656657081085?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3864918656657081085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3864918656657081085' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3864918656657081085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3864918656657081085'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/06/finding-image-type-for-file.html' title='Finding Image Type for a file'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5295375393436331191</id><published>2007-06-08T14:51:00.000-07:00</published><updated>2007-06-08T15:21:46.559-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Finding mime type of any file</title><content type='html'>Hemant recently told me about this cool API in java.net.URLConnection which can tell you the mime type for common file types. &lt;p&gt;&lt;br /&gt;&lt;b&gt;guessContentTypeFromName(String name)&lt;/b&gt; - that simply checks the extension of the file name specified and gets the mime type from a static map it maintains. This can be very useful in many scenarios. The map it uses is quite extensive and contains almost all the mime types.&lt;br&gt;&lt;br /&gt;But this has a problem. What if some one has renamed a gif to jpg? This method will say that the file is a jpg image whereas it was a gif.&lt;br /&gt;&lt;br /&gt;Thankfully there is another method in the same class which can address this problem. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;guessContentTypeFromStream(InputStream stream)&lt;/b&gt; - which reads the stream, takes a look at the initial bits of the file and uses that to determine the file type.&lt;br /&gt;This method does a check for the following mime types :-&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;- application/java-vm&lt;br /&gt;- application/x-java-serialized-object&lt;br /&gt;- text/html&lt;br /&gt;- application/xml&lt;br /&gt;- image/gif&lt;br /&gt;- image/x-bitmap&lt;br /&gt;- image/x-pixmap&lt;br /&gt;- image/png&lt;br /&gt;- image/jpeg&lt;br /&gt;- image/jpg&lt;br /&gt;- image/vnd.fpx&lt;br /&gt;- audio/basic&lt;br /&gt;- audio/x-wav&lt;br /&gt;&lt;/pre&gt;&lt;br&gt;&lt;br /&gt;Though this method leaves out many of other common types such as mp3, it is still very useful. This makes it so easy to find out the type of an image.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5295375393436331191?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5295375393436331191/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5295375393436331191' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5295375393436331191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5295375393436331191'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/06/finding-mime-type-of-any-file.html' title='Finding mime type of any file'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-3824186492805447490</id><published>2007-06-02T08:01:00.000-07:00</published><updated>2007-06-07T12:30:55.664-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>ListToArray with empty elements - Part II</title><content type='html'>Yesterday I had posted about how to &lt;a href="http://coldfused.blogspot.com/2007/06/listtoarray-with-empty-elements.html"&gt;convert List to Array&lt;/a&gt; that would include empty elements. &lt;a href="http://cfblog.griefer.com/"&gt;Charlie&lt;/a&gt; rightly pointed out a problem with that which is - it does not consider the empty elements at the end of the list.&lt;br /&gt;So, a list "a,b,,c,d,," when converted to array will have only 5 elements instead of 7.&lt;br /&gt;&lt;p&gt;Incidently Charlie had also talked about the same some time back &lt;a href="http://cfblog.griefer.com/index.cfm/id/make_like_a_banana_and_split"&gt;here&lt;/a&gt; and he mentions another problem with this approach. The array that is returned after split method is read only and you can not modify this array.&lt;br /&gt;In order to address both these, I had to write this UDF which I guess many people would have written anyways..&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;Strike&gt;&lt;br /&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;   function list2Array(list)&lt;br /&gt;   {&lt;br /&gt;       var endCommaCount = 0;&lt;br /&gt;       var i = 0; var c = "";&lt;br /&gt;       var stringForSplit = ""; var retList=""; var arr = "";&lt;br /&gt;&lt;br /&gt;       for(i=len(list); i &amp;gt; 0; i--)&lt;br /&gt;       {&lt;br /&gt;           c = list.charAt(i-1);&lt;br /&gt;           if(c == ',')&lt;br /&gt;               endCommaCount++;&lt;br /&gt;           if( c != ',' &amp;&amp;amp; c != ' ')&lt;br /&gt;               break;&lt;br /&gt;       }&lt;br /&gt;       retlist = ArrayNew(1);&lt;br /&gt;&lt;br /&gt;       if(i != 0)&lt;br /&gt;       {&lt;br /&gt;           stringForSplit = left(list, i);&lt;br /&gt;           arr = stringForSplit.split("\s*,\s*");&lt;br /&gt;&lt;br /&gt;           for(i = 1; i &amp;lt;= ArrayLen(arr); i++)&lt;br /&gt;               ArrayAppend(retList, arr[i]);&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       for(i = 0; i &amp;lt; endCommaCount; i++)&lt;br /&gt;           ArrayAppend(retList, "");&lt;br /&gt;&lt;br /&gt;       return retList;&lt;br /&gt;   }&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;br /&gt;&lt;/Strike&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;UPDATE : &lt;/b&gt;Thanks to Andrew Clark for the split tip which makes it more slim and elegant. The code above changes like&lt;br /&gt;&lt;/p&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;   function list2Array(list)&lt;br /&gt;   {&lt;br /&gt;       var i = 0; &lt;br /&gt;       var retlist = ArrayNew(1);&lt;br /&gt;       var arr = list.split(",", -1);&lt;br /&gt;       for(i = 1; i &amp;lt;= ArrayLen(arr); i++)&lt;br /&gt;           ArrayAppend(retList, arr[i]);&lt;br /&gt;       return retList;&lt;br /&gt;   }&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Lets test this udf and see if it works..&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset cflist = "a,b,,c,,d, ,"&amp;gt;&lt;br /&gt;&amp;lt;cfset cfarr1 = ListToArray(cflist)&amp;gt;&lt;br /&gt;&amp;lt;cfset ArrayAppend(cfarr1, "END")&amp;gt;&lt;br /&gt;&amp;lt;cfset cfarr2 = List2Array(cflist)&amp;gt;&lt;br /&gt;&amp;lt;cfset ArrayAppend(cfarr2, "END")&amp;gt;&lt;br /&gt;&lt;br /&gt;With CF Function : &amp;lt;cfdump var="#cfarr1#" format="text"&amp;gt;&lt;br /&gt;With UDF : &amp;lt;cfdump var="#cfarr2#" format="text"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;And this produces this result.&lt;br /&gt;With CF Function :&lt;br /&gt;&lt;pre&gt;array - Top 6 of 6 rows&lt;br /&gt;&lt;br /&gt;1) a&lt;br /&gt;2) b&lt;br /&gt;3) c&lt;br /&gt;4) d&lt;br /&gt;5) &lt;br /&gt;6) END&lt;br /&gt;&lt;/pre&gt;With UDF :&lt;br /&gt;&lt;pre&gt;array - Top 9 of 9 rows&lt;br /&gt;&lt;br /&gt;1) a&lt;br /&gt;2) b&lt;br /&gt;3) [empty string]&lt;br /&gt;4) c&lt;br /&gt;5) [empty string]&lt;br /&gt;6) d&lt;br /&gt;7) [empty string]&lt;br /&gt;8) [empty string]&lt;br /&gt;9) END&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;One thing to note here is that I am using new cfscript operators added in ColdFusion 8 which is so cool!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-3824186492805447490?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/3824186492805447490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=3824186492805447490' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3824186492805447490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/3824186492805447490'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/06/listtoarray-with-empty-elements-part-ii.html' title='ListToArray with empty elements - Part II'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8885166728026348714</id><published>2007-06-01T12:13:00.000-07:00</published><updated>2007-06-07T12:10:15.564-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>ListToArray with empty elements</title><content type='html'>Recently there was a request on our forum to support empty elements in ListToArray function for Scorpio i.e ColdFusion 8. it might not be done in Scorpio since it is too late to add a new function. However it can be very easily achieved in cfm itself. Here is the code to do it.&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset cflist="a,b,,c,,,d"&amp;gt;&lt;br /&gt;&amp;lt;cfset cfarr1 = ListToArray(cflist)&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;strike&gt;&amp;lt;cfset cfarr2 = cflist.split(",")&amp;gt;&lt;/strike&gt;&lt;br /&gt;&amp;lt;cfset cfarr2 = cflist.split(",", -1)&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cfdump var="#cfarr1#"&amp;gt;&lt;br /&gt;&amp;lt;cfdump var="#cfarr2#"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cfscript&amp;gt;&lt;br /&gt;for(i=1; i &amp;lt;= ArrayLen(cfarr2); i++)&lt;br /&gt;{&lt;br /&gt; writeoutput("Element #i# : #cfarr2[i]# &amp;lt;br&amp;gt;");&lt;br /&gt;}&lt;br /&gt;&amp;lt;/cfscript&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As you can see, 3rd, 5th and 6th element in this cfarr2 are empty.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8885166728026348714?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8885166728026348714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8885166728026348714' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8885166728026348714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8885166728026348714'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/06/listtoarray-with-empty-elements.html' title='ListToArray with empty elements'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-4739698871028175559</id><published>2007-06-01T11:26:00.000-07:00</published><updated>2007-06-01T11:45:13.859-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><title type='text'>ColdFusion 8 beta has arrived</title><content type='html'>I think I am the last person to say that &lt;a href="http://labs.adobe.com/technologies/coldfusion8"&gt;ColdFusion 8 i.e Scorpio beta&lt;/a&gt; is out. Yayyy !!! :)&lt;br /&gt;&lt;br /&gt;And that means I am back on blogsphere after a long hiatus. Seriosuly, what a fabulous journey it has been! It is a result of nearly one and half year of hard work, huge amount of research, so many design discussions, fights over nitties-gritties of features, many spec review meetings (which many a times reminded me of the college time ragging or soap box for elections at IIT kgp), many beer parties (because some one was beer boy coz he broke the build) and eating rubber chicken few times (becoz the build was broken again !!) etc etc etc.. -- all to ensure that there is enough sting in the Scorpio. :)&lt;br /&gt;&lt;br /&gt;Everyone of us in the team is really proud of the stuff that we have built and I am sure people gonna love it.&lt;br /&gt;&lt;br /&gt;And we are not done yet! Ashwin's &lt;a href="http://blogs.sanmathi.org/ashwin/2007/05/31/behind-the-scenes/"&gt;cartoon&lt;/a&gt; says it all !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-4739698871028175559?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/4739698871028175559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=4739698871028175559' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4739698871028175559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4739698871028175559'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/06/coldfusion-8-beta-has-arrived.html' title='&lt;a href=&quot;http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_adobecf8_beta&quot;&gt;ColdFusion 8 beta has arrived&lt;/a&gt;'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8316703280575581641</id><published>2007-03-02T11:50:00.000-08:00</published><updated>2007-03-02T12:03:14.310-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>Use Java 5 feature in Jdk1.4</title><content type='html'>I have been getting the itch for a long tome to use Java 5 features like generics, new concurrency (java.util.concurrent), autoboxing, "for each" loop and many more. But sadly I can not do it at work because ColdFusion has to be supported on all application servers. Since many of the application servers are still on J2EE 1.4 and not all of them are compatible with Java 5, we have to write JDK1.4 compliant code.  Which means that all those wonderful features of Java5 can not be used for some more time to come. Or so I thought until yesterday when I read Brian Goetz's (of "Java concurrency in practice" fame) &lt;a href="http://www-128.ibm.com/developerworks/java/library/j-jtp02277.html?ca=drs-"&gt;article&lt;/a&gt; which says that we can use some of the Java features in JDK1.4 also.&lt;br /&gt;At first I was kind of puzzled as in how could that be possible? Did they had these features and they just did not mention about it in JDK1.4 or probably they just sneaked it in 1.4 in last moment but not talk about it because of some reasons.&lt;br /&gt;&lt;br /&gt;It dawned to me when I went halfway through the article. It looks like most of these new syntaxes did not need any change in the bytecode instruction set which means that the compiler would generate the same bytecodes or instruction set for it as it would have for equivalent code without using these features. So it should be possible to use a class created by java5 compiler in 1.4. But don't we get UnsupportedClassVersionError when we try to do that? &lt;br /&gt;&lt;br /&gt;Here is the catch. Due to some reasons they had to change the class version and that is why this UnsupportedClassVersionError. However these guys added a flag to java compiler (which ofcourse is undocumented) that can allow this. You need to invoke javac with "-source 1.5 -target jsr14" option and this will generate 1.4 compatible bytecodes for java5 syntax. This means I can happily write my code using generics, autoboxing, for..each loop, compile it with java5 compiler with this flag and be assured that this can run on 1.4 VM also.&lt;br /&gt;&lt;br /&gt;That leaves one more set of features i.e; new concurreny, which I really really like in java5 and want to use. Thankfully some guys at &lt;a href="http://dcl.mathcs.emory.edu/"&gt;Distibuted Computing Lab at Emory University&lt;/a&gt; have &lt;a href="http://dcl.mathcs.emory.edu/util/backport-util-concurrent/"&gt;backported java5 concurrency&lt;/a&gt; (java.uti.concurrent) features that can be used in java 1.3+. I have infact used it and it is awesome !&lt;br /&gt;&lt;br /&gt;So most of the juicy stuffs that were added in java5 can run on 1.4. Off to checking it out little more. :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8316703280575581641?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8316703280575581641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8316703280575581641' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8316703280575581641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8316703280575581641'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/03/use-java-5-feature-in-jdk14.html' title='Use Java 5 feature in Jdk1.4'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-6592338870435065228</id><published>2007-03-01T07:12:00.000-08:00</published><updated>2007-03-01T07:50:04.768-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>java.net article on ColdFusion and JavaEE</title><content type='html'>I found this &lt;a href="http://today.java.net/pub/a/today/2007/02/27/coldfusion-for-jsp-developers.html"&gt;interesting article&lt;/a&gt; by Kola Oyedeji on &lt;a href="http://java.net"&gt;java.net&lt;/a&gt;. He talks about integration between ColdFusion and JavaEE and how this could be of interest to JSP developers.&lt;br /&gt;We in our team here have discussed it so many times that why can not ColdFusion be used by J2EE/JSP developers or enterprises that standardize on J2EE. ColdFusion is a pure J2EE solution, runs on all the major applications servers, is so feature rich, so productive that it should be a no brainer for everyone to adapt this. And to this when I add the features that we are adding in Scorpio, it makes even more sense. I don't think there is any other platform which can come even close to CF in terms of features and productivity.&lt;br /&gt;At MAX, I had a conversation with one of our customers and he said something very interesting. His client wanted a pure J2EE solution and his competitors were asking for nearly 6 months to implement this. So this guy did everything in CF, bundled it as an ear (that can be deployed on application server) and shipped in flat one month !! And his client never ever thought that this was a CF application. :D&lt;br /&gt;&lt;br /&gt;Good to see this kind of article on a java website.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-6592338870435065228?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/6592338870435065228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=6592338870435065228' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6592338870435065228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6592338870435065228'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/03/article-on-coldfusion-and-javaee.html' title='java.net article on ColdFusion and JavaEE'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-6673617690776772194</id><published>2007-02-25T12:12:00.003-08:00</published><updated>2007-02-25T12:32:34.398-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='red-x'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Accessing password protected URL</title><content type='html'>How do you access a password protected URL (requiring basic authentication) programmatically? well, there are two ways&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;If you know that the URL is protected : This is the simple one. Since you know the URL is protected, add the required authorization header in the request and you are done. What if you are not making the socket connection but instead using java.net.URL or java.net.URLConnection to retrieve the content of url? You can use setRequestProperty() method of URLConnection to add any request header you want. So the code would look like&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;URL url = new URL(someurlstring)&lt;br /&gt;URLConnection conn = url.openConnection();&lt;br /&gt;String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes());&lt;br /&gt;conn.setRequestProperty ("Authorization", "Basic " + encoding);&lt;br /&gt;InputStream in = conn.getInputStream()&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;What if you dont know in advance whether the URL is protected or not? You can not arbitrarily add the authorization heder for all the URLs. The answer to this is "java.net.Authenticator". You need to install an instance of java.net.Authenticator using setDefault() method of Authenticator. Whenever URLConnection sees that the url is protected, it will use this installed authenticator to get the username and password and set the required authorization header automatically.&lt;br /&gt;Here is how the code snippet for doing this&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;Authenticator.setDefault(new MyAuthenticator());&lt;br /&gt;....&lt;br /&gt;&lt;br /&gt;public class MyAuthenticator extends Authenticator&lt;br /&gt;{&lt;br /&gt; protected PasswordAuthentication getPasswordAuthentication()&lt;br /&gt; {&lt;br /&gt;     return new PasswordAuthentication ("username", "password");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;This particular technique is particularly useful for people who need a workaround for retrieving password protected images in cfdocument. Here is what you need to do.&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Use the source below to create Authenicator class&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;import java.net.*;&lt;br /&gt;public class MyAuthenticator extends Authenticator&lt;br /&gt;{&lt;br /&gt;    private String user;&lt;br /&gt;    private String passwd;&lt;br /&gt;&lt;br /&gt;    public MyAuthenticator(String user, String passwd)&lt;br /&gt;    {&lt;br /&gt;        this.user = user;&lt;br /&gt;        this.passwd = passwd;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected PasswordAuthentication getPasswordAuthentication()&lt;br /&gt;    {&lt;br /&gt;        return new PasswordAuthentication(user, passwd.toCharArray());&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;Compile this and put MyAuthenticator.class in wwwroot/WEB-INF/classes.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Put the following code in your application.cfm or application.cfc&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfif not IsDefined("Application.authenticator")&amp;gt;&lt;br /&gt;      &amp;lt;!--- Do initializations ---&amp;gt;&lt;br /&gt;      &amp;lt;cfset authenticator= createObject("java", "java.net.Authenticator")&amp;gt;&lt;br /&gt;      &amp;lt;cfset myauthenticator = createObject("java", "MyAuthenticator").init("username", "password")&amp;gt;&lt;br /&gt;      &amp;lt;cfset authenticator.setDefault(myauthenticator)&amp;gt;&lt;br /&gt;      &amp;lt;cfset Application.authenticator=myauthenticator&amp;gt;&lt;br /&gt;&amp;lt;/cfif&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;replace "username" and "password" with actual username and password.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;give the request for the cfdocument page for which you were getting the red-x for image. The images should appear this time.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-6673617690776772194?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/6673617690776772194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=6673617690776772194' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6673617690776772194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/6673617690776772194'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/02/accessing-password-protected-url_5016.html' title='Accessing password protected URL'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-7838089953543236675</id><published>2007-02-15T13:07:00.000-08:00</published><updated>2007-02-15T13:10:54.980-08:00</updated><title type='text'>A page in CFSwitch-CFCase' diary</title><content type='html'>Undoubtedly I am one of the most powerful programming construct of ColdFusion language. And definitely more powerful than all my cousins in other programming languages. All my cousins and even my brother (read java switch-case) work only on integers but I work on almost every kind of objects be it string or any numeric data or even date. Since I can work on almost all datatypes, I make cf developers life so much simpler. I was created this way because the world I was going to be in was UnTyped - where every one was equal and where there was no discrimination between datatypes and I really thank God (ColdFusion Architects) for creating such a wonderful world.&lt;br /&gt;Recently I heard someone talking about me that I am not as fast as my cousins. Some one even talked about ignoring me and taking help of kiddo cfif-cfelse. I dont want to say anything against anyone coz I know "with great power comes great responsibility err..cost". &lt;br /&gt;&lt;br /&gt;Its sheer hardwork that makes me so much more powerful than all my cousins. This is what I do when any object comes to me. First I try to see if it is numeric. I do that because that is what all my cousins are used to and I have to remain as fast as them in that case. If it is not numeric, then I check if it can be date. If it is not even date, I try converting it in String. Once I arrive at the data, I use my own data structure to match it with appropriate CASE. So when the data is string, i will take some more time as compared to what i will take when data is numeric. Is that so bad? My cousins dont even do that!&lt;br /&gt;&lt;br /&gt;Sometimes I compare myself to a busy lawyer who likes working on many CASEs. I dont like to work just for 2-3 cases. I prefer my grandson cfif-cfelse take care of those small no of cases.&lt;br /&gt;I hope someday people will read these pages and if even after reading this they think that I am too slow and I should be ignored I only want to say "God, forgive them, for they dont know what they are doing!".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-7838089953543236675?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/7838089953543236675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=7838089953543236675' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/7838089953543236675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/7838089953543236675'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/02/page-in-cfswitch-cfcase-diary.html' title='A page in CFSwitch-CFCase&apos; diary'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-8736407136452249320</id><published>2007-02-15T11:39:00.000-08:00</published><updated>2007-02-15T11:47:05.670-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Performance Tips : ColdFusion List</title><content type='html'>how many of you have written/seen code like this?&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset mylist="jan,feb,mar,apr,may,jun,jul,sep,oct,nov,dec"&amp;gt;&lt;br /&gt;&amp;lt;cfloop from="1" to=#ListLen(mylist)# index="i"&amp;gt;&lt;br /&gt; &amp;lt;cfset month = ListGetAt(mylist, i)&amp;gt;&lt;br /&gt; &amp;lt;!--- do something with this month ---&amp;gt;&lt;br /&gt; &amp;lt;cfoutput&amp;gt;#month#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;While there is nothing wrong with it syntactically or functionally, performance wise it is very poor. Why? ColdFusion list is nothing but String (delimited by delimiter). ColdFusion does not have any way to build any intelligence to keep it in any other datastructure because you can use it like a normal string also. So what happens when you call any List function on this string? We parse the string using the delimiter and get the delimited tokens and process that.&lt;br /&gt;Now lets take ListGetAt(list, index) function. It will keep parsing and getting the token unless it reaches the required index. Imagine doing in a loop. We will be parsing the same string again and again and traversing from the beginning everytime till we reach the next loop index. So, in the Nth iteration, it will start from beginning and tokenize N times. Thus by the time you have completed the loop, you have parsed/tokenized the string N*(N+1)/2 times. Isn't that too costly? Lesson - Never ever use ListGetAt() in a loop. Either iterate using &lt;cfloop list="#mylist#"&gt; OR convert the list into array using ListToArray() and iterate over it. Using cfloop is the most optimized way to do this.&lt;br /&gt;&lt;br /&gt;Even if you are not iterating over list but you need to call ListGetAt() many times, it is better to convert it to array and then search the index in that.&lt;br /&gt;&lt;br /&gt;Same thing applies to search functions like ListFind, ListContains etc. If you need to call these multiple times on the same list, you will be better off converting the list to array and searching in that.&lt;br /&gt;&lt;br /&gt;If you need to append many items to the list, then also you will get a better performance by converting the list to array and doing all appends on that.&lt;br /&gt;&lt;br /&gt;This does not mean you should not use list at all or you should always convert the list to array and work on that. If the number of operations that you are doing on the list is less, you should stick to list because converting the list to array is also costly. If you are inserting an element in the middle of list, list will be better than array in most cases.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-8736407136452249320?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/8736407136452249320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=8736407136452249320' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8736407136452249320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/8736407136452249320'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/02/performance-tips-coldfusion-list.html' title='Performance Tips : ColdFusion List'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-5777285429920615388</id><published>2007-02-06T07:04:00.000-08:00</published><updated>2007-02-06T07:08:55.650-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='optimization'/><title type='text'>ColdFusion Array : pass by reference or Value.</title><content type='html'>&lt;a href="http://www.bennadel.com"&gt;Ben&lt;/a&gt; rightly pointed out in my &lt;a href="http://coldfused.blogspot.com/2007/01/string-concatenation-optimization.html"&gt; last post &lt;/a&gt; that since ColdFusion array are always passed by value, the second technique can not be used if you want to build the array over multiple method calls. In each of the function call, ColdFusion will create a copy of the array passed and that cost (cost of creating a new instance and copying old array to new one) might even exceed the cost of appending string.&lt;br /&gt;&lt;br /&gt;ColdFusion array is one unique data structure in ColdFusion. Unique in the sense that this is the only data structure that is passed by value and not by reference. I do feel it is a limitation sometimes but thats legacy and can not be changed. (You would not want us to break your code. Would you? ;) )&lt;br /&gt;&lt;br /&gt;There does exist one hack if you absolutely need to pass the array by reference. Here is a code snippet that uses pass by reference.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset x = ArrayNew(1)&amp;gt;&lt;br /&gt;&amp;lt;cfloop from=1 to=5 index=i&amp;gt;&lt;br /&gt; &amp;lt;cfset Arrayappend(x,"something")&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cfset x = CreateObject("java", "java.util.ArrayList").init(x)&amp;gt;&lt;br /&gt;&amp;lt;cfset foo(x)&amp;gt;&lt;br /&gt;&amp;lt;cfset foo(x)&amp;gt;&lt;br /&gt;&amp;lt;cfset x[8] = "after the method call"&amp;gt;&lt;br /&gt;&amp;lt;cfset x[9] = "end of method call"&amp;gt;&lt;br /&gt;&amp;lt;cfset foo(x)&amp;gt;&lt;br /&gt;&amp;lt;cfdump var="#x#"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cffunction name="foo"&amp;gt;&lt;br /&gt; &amp;lt;cfargument name="arr"&amp;gt;&lt;br /&gt; &amp;lt;cfset ArrayAppend(arr, "from function")&amp;gt;&lt;br /&gt;&amp;lt;/cffunction&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;So what did we do here? We created an ArrayList from the ColdFusion array. Since ColdFusion Array is an implementation of java.util.List,  almost all Array functions work on all implementations of java.util.List. And this list implementation will not be passed by value but will be passed by reference. Thats the power of using java in ColdFusion !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-5777285429920615388?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/5777285429920615388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=5777285429920615388' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5777285429920615388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/5777285429920615388'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/02/coldfusion-array-pass-by-reference-or.html' title='ColdFusion Array : pass by reference or Value.'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-1150903427508881034</id><published>2007-02-05T10:26:00.000-08:00</published><updated>2007-02-05T10:41:17.925-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='jvm'/><title type='text'>The Mystery of  "Too many open files"</title><content type='html'>Last week we saw an interesting problem while running the regression tests on Linux. Immediately after the tests were started, the VM started throwing error &lt;b&gt;"FileNotFoundException : Too many open files"&lt;/b&gt;. Ofcourse the files were there but the VM was trying to say that there are too many file descriptors open which were not closed. It was hitting the open file limit set by the OS. This was kind of absurd because we always close all the files that we open. And moreover we had never seen this problem before. So we started suspecting 1.6 VM on which we were running it.&lt;br /&gt;&lt;br /&gt;Immediately after this, it got worse. The exception changed into &lt;b&gt;"SocketException: Too many open files"&lt;/b&gt; and all the socket connection started getting rejected. So merely after serving 100 requests, the server was down to its knees. &lt;br /&gt;&lt;br /&gt;A quick google search suggested to increase the open file descriptor limit on the machine. &lt;br /&gt;&lt;br /&gt;"ulimit -aH" that gives the max limit for number of open files returned 1024.&lt;br /&gt;&lt;br /&gt;I added every possible way to increase it. Here are few&lt;br /&gt;&lt;br /&gt;1. In /etc/security/limits.conf &lt;br /&gt;*       soft    nofile  1024&lt;br /&gt;*       hard    nofile  65535&lt;br /&gt;2. Increase ulimit by "ulimit -n 65535"&lt;br /&gt;3. echo 65535 &amp;gt; /proc/sys/fs/file-max&lt;br /&gt;4. In /etc/sysctl.conf &lt;br /&gt;fs.file-max=65535&lt;br /&gt;&lt;br /&gt;Increasing file descriptor limit did not help much either. Even after increasing this limit, we were still getting this error.And then &lt;b&gt;Sanjeev&lt;/b&gt; (another brilliant CF engineer with an amazing sense of humour) cracked it !!&lt;br /&gt;Just before we started getting these errors, there was another error which I had overlooked assuming it was test problem which infact was the clue.&lt;br /&gt;The error was something like&lt;br /&gt;coldfusion.jsp.CompilationFailedException: Errors reported by Java compiler: error: error reading /opt/coldfusionscorpio/lib/./././././././././././././././././././././././././././././&lt;br /&gt;././././././././././././././././././././././././././././././././././././././././././.&lt;br /&gt;/././././././././././././././././././././././././././././././././././././././././././&lt;br /&gt;././././././././././././././././././././././././././././././././././././././././././.&lt;br /&gt;/././././././././././././././././././././././././././././././././././././././././././&lt;br /&gt;././././././././././././././././././././././././././././././././././././././././././.&lt;br /&gt;/././././././././././././././././././././././././././././././././././././././././././&lt;br /&gt;././././././././././././././././././././././././././././././././././././././././././.&lt;br /&gt;/././././././././././././././././././././././././././././././././././././././././././&lt;br /&gt;././././././././././././././././././././././././././././././././././././././././././.&lt;br /&gt;/././././././././././././././././././././././././././././././././././././././././././&lt;br /&gt;././././././././././././././././././././././././././././././././././....&lt;br /&gt; at coldfusion.jsp.JavaCompiler.compileClass(JavaCompiler.java:138)&lt;br /&gt;&lt;br /&gt;Sanjeev ran it through the debugger and he nailed the culprit. It was something which no one had even suspected. It was javac. :)&lt;br /&gt;We had hit upon a Sun's bug in javac where if the classpath contains a jar which has a manifest and manifest contains classpath entry with relative paths of other jars as well as path to itself, javac goes in an infinite loop. (Sun's bug no  &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6400872"&gt;6400872&lt;/a&gt;, &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6446657"&gt;6446657&lt;/a&gt;, &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6456960"&gt;6456960&lt;/a&gt;, &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6485027"&gt;6485027&lt;/a&gt;, &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6206485"&gt;6206485&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;I dont have the source for javac to pin point what exactly it did, but probably it kept opening all the entries in the classpath and because of the stack overflow it could not close those files - hence reaching the max limit of open file descriptors. This was a third party jar that had this manifest entry. Once we found the problem, the solution was simple - just remove the classpath entry from the manifest! Whew !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-1150903427508881034?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/1150903427508881034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=1150903427508881034' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/1150903427508881034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/1150903427508881034'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/02/mystery-of-too-many-open-files.html' title='The Mystery of  &quot;Too many open files&quot;'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-4253244031099444492</id><published>2007-01-30T11:01:00.000-08:00</published><updated>2007-02-05T07:21:05.308-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='optimization'/><title type='text'>String Concatenation optimization</title><content type='html'>String concatenation is one of the most common, but, a pretty  expensive operation. It can hit the performance severly if not used correctly. The performance goes down drastically if you append strings using '&amp;' OR ListAppend() in a loop. I have seen application performance improving by 50-100% just by optimizing String concatenation (though that depends on how much concatenation is used in the app). So what do you about it?&lt;br /&gt;The simplest and the most optimized way to do these append operations is using java's &lt;span style="font-weight: bold;"&gt;StringBuffer&lt;/span&gt;. (I am sure you must be aware of it but still.. :)) .&lt;br /&gt;The code would look like&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset sb = createObject("java", "java.lang.StringBuffer")&amp;gt;&lt;br /&gt;&amp;lt;cfloop from=1 to=100 index=i&amp;gt;&lt;br /&gt;  &amp;lt;cfset sb.append("something")&amp;gt;&lt;br /&gt;  &amp;lt;cfset sb.append(i)&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&amp;lt;cfset result=sb.toString()&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Sometimes I feel that we should have a datastructure like this in ColdFusion directly but again I think whats wrong with using StringBuffer? Its like any other function which we would create. Isn't it so?&lt;br /&gt;&lt;br /&gt;If you are a puristic and don't want to use any java API inside your CF app, there is another simple way to do the same thing. It uses ColdFusion Array to do the same thing what StringBuffer does. Instead of appending the string in the buffer, you can append to the array using ArrayAppend() and then once you are done and want to get the string back, use ArrayToList() with empty string ("") as delimiter. The code would look like&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset arr = ArrayNew(1)&amp;gt;&lt;br /&gt;&amp;lt;cfloop from=1 to=100 index=i&amp;gt;&lt;br /&gt;  &amp;lt;cfset ArrayAppend(arr, "something")&amp;gt;&lt;br /&gt;  &amp;lt;cfset ArrayAppend(arr, i)&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&amp;lt;cfset result=ArrayToList(arr,"")&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This would give a much better performance as compared to concatenation using '&amp;' or using ListAppend() but will have lower performance as compared to StringBuffer. That is because of the overhead of Array object creation and array append operation. ArrayToList() will anyway create the string buffer and append the strings&lt;br /&gt;&lt;br /&gt;You should use '&amp;amp;' or ListAppend() only when there are only 2-3 strings to be concatenated. Otherwise always use either of the two techniques above.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-4253244031099444492?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/4253244031099444492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=4253244031099444492' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4253244031099444492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/4253244031099444492'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/01/string-concatenation-optimization.html' title='String Concatenation optimization'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-116906379049528477</id><published>2007-01-17T11:50:00.000-08:00</published><updated>2007-01-17T12:05:09.096-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Optimizations with literals</title><content type='html'>Look at these two pieces of code carefully. Is there any difference between these two apart from the fact that the second one is shorter?&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset x = "sun,mercury,venus,earth,mars,jupiter,saturn,uranus,pluto,neptune"&amp;gt;&lt;br /&gt;&amp;lt;cfset y = ListSort(x,"text")&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;and&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset y = ListSort("sun,mercury,venus,earth,mars,jupiter,saturn,uranus,pluto,neptune","text")&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;If you think there is not much, read on.&lt;br /&gt;&lt;br /&gt;There is a huge difference between these two piece of code - in terms of performance. The second one will have much better performance as compared to the first one. How?? Because the ListSort() method in the second case will not even be executed in the page request. Still scratching your head?&lt;br /&gt;&lt;br /&gt;It is because of the intelligence that is built into CFML compiler (really superb code written by Edwin Smith). During compilation, it analyzes all the code and wherever there is a literal or functions executing literals, it tries to optimize it. In the second piece here, it sees that ListSort method is being called on a literal and it can be done statically. So compiler will execute this call during compilation itself and set the sorted value on 'y'. During the page execution, only thing that will get executed will be an assignment. Smart.. isn't it? Even java compiler, which does quite a many compile time optimization for java source files, does not have this intelligence of executing calls at compile time :)&lt;br /&gt;&lt;br /&gt;It is not only about 'ListSort'. This is true for most of those CF functions which can work on a literal and can return a literal.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-116906379049528477?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/116906379049528477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=116906379049528477' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/116906379049528477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/116906379049528477'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/01/optimizations-with-literals.html' title='Optimizations with literals'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-116861460940707835</id><published>2007-01-12T07:02:00.000-08:00</published><updated>2007-01-12T07:32:33.746-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Extend CF native Objects - Harnessing Java</title><content type='html'>Since Coldfusion native objects are java objects, you can harness the java APIs to extend the functionality of these objects. In this post we will take CF &lt;span style="font-weight: bold;"&gt;Array&lt;/span&gt; and see how we can use these APIs to get some cool functionalities from them.&lt;br /&gt;&lt;br /&gt;ColdFusion array is actually an implementation of java list (java.util.List). So all the list methods are actually available for Array.&lt;br /&gt;CF provides most of the list functionality using Array functions but there are few things possible with java list which you can not do directly with CF functions.&lt;br /&gt;&lt;br /&gt;1. &lt;span style="font-weight: bold;"&gt;Merge &lt;/span&gt;:  Lets say you create two arrays and you want to merge these two arrays to create one bigger array. There is no CF function to do this.&lt;br /&gt;However You can call List.addAll() methods to do it.&lt;br /&gt;&lt;br /&gt;Here is how it would look.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;I am creating array this way just because it is easier and I don't have to write whole lot of code :)&lt;/span&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset y = ListToArray("rupesh,tom,damon,hemant,ashwin,ram,prank,sanjeev")&amp;gt;&lt;br /&gt;&amp;lt;cfset z = ListToArray("dean,manju,jason,tim")&amp;gt;&lt;br /&gt;&amp;lt;cfset y.addAll(z)&amp;gt;&lt;br /&gt;&amp;lt;cfdump var="#y#"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;2. &lt;span style="font-weight: bold;"&gt;Merge in middle&lt;/span&gt; : Lets say you want to add the second array somewhere in the middle of first array say after 4 elements. The code would look like&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset y = ListToArray("rupesh,tom,damon,hemant,ashwin,ram,prank,sanjeev")&amp;gt;&lt;br /&gt;&amp;lt;cfset z = ListToArray("dean,manju,jason,tim")&amp;gt;&lt;br /&gt;&amp;lt;cfset y.addAll(4, z)&amp;gt;&lt;br /&gt;&amp;lt;cfdump var="#y#"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;3. &lt;span style="font-weight: bold;"&gt;Search &lt;/span&gt;: I have heard people complaining that there is no find method in Array. Actually you had it all the time. Just that it was hidden :)&lt;br /&gt;You can use List.Contains() or List.indexOf() methods to achieve that. Here is the code.&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset y = ListToArray("rupesh,tom,damon,hemant,ashwin,ram,prank,sanjeev")&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;Contains Hemant: #y.contains("hemant")#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;Index of damon : #y.indexof("damon")#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Please note that the java index starts at 0 where as CF index starts at 1. So the index here will be 2. You must also note that since java is case sensitive, this search will also be case sensitive. To build case insensitiveness, you will have to make the list as well as the search in same case - either uppercase it or lowercase it.&lt;br /&gt;&lt;br /&gt;4. &lt;span style="font-weight: bold;"&gt;Search whole array&lt;/span&gt; : You can also search if all the elements of one array are present in another array using containsAll() method of java list.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset y = ListToArray("rupesh,tom,damon,hemant,ashwin,ram,prank,sanjeev")&amp;gt;&lt;br /&gt;&amp;lt;cfset z = ListToArray("ram,prank,rupesh")&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt; y Contains z: #y.containsAll(z)#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;5. &lt;span style="font-weight: bold;"&gt;Equality check&lt;/span&gt; : You can find out if two arrays are same or not using list's equals method.&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset y = ListToArray("rupesh,tom,damon,hemant,ashwin,ram,prank,sanjeev")&amp;gt;&lt;br /&gt;&amp;lt;cfset z = ListToArray("dean, manju,jason,tim")&amp;gt;&lt;br /&gt;&amp;lt;cfset x = ListToArray("rupesh,tom,damon,hemant,ashwin,ram,prank,sanjeev")&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;x equals y : #x.equals(y)#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;x equals z : #x.equals(z)#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;6. &lt;span style="font-weight: bold;"&gt;RemoveAll &lt;/span&gt;: You can remove all the elements of one array from the second array using removeAll()&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfset y = ListToArray("rupesh,tom,damon,hemant,ashwin,ram,prank,sanjeev")&amp;gt;&lt;br /&gt;before removal &amp;lt;cfdump var="#y#"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cfset z = ListToArray("ram,prank,tom")&amp;gt;&lt;br /&gt;&amp;lt;cfset y.removeAll(z)&amp;gt;&lt;br /&gt;After removal &amp;lt;cfdump var="#y#"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Go ahead and play around with it!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-116861460940707835?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/116861460940707835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=116861460940707835' title='26 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/116861460940707835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/116861460940707835'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2007/01/extend-cf-native-objects-harnessing.html' title='Extend CF native Objects - Harnessing Java'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>26</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-115886190309049409</id><published>2006-09-21T10:35:00.000-07:00</published><updated>2006-09-21T11:06:19.603-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='Scorpio'/><title type='text'>Scorpion Queen !</title><content type='html'>When Tim asked for &lt;a href="http://www.buntel.com/blog/index.cfm?mode=entry&amp;entry=895C43D8-4E22-1671-50068A0F94843D2C"&gt;spiffy Scorpio logo&lt;/a&gt;, a few CF engineers (Sanjeev, Chandan, Jayesh, Sandeep and Vamsee. special mention - Hemant &amp; Praveen.) got together to create her. Of course they didnt use Photoshop. We are very much used to Whiteboard :)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/1031/809/1600/DSC01037.jpg"&gt;&lt;img margin:0 0 10px 10px;cursor:pointer; cursor:hand; src="http://photos1.blogger.com/blogger/1031/809/320/DSC01037.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Did you notice the cool scorpio tatoo she is wearing. And No, she would not execute &lt;a href="http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:249450"&gt;&amp;lt;CFLAPDANCE /&amp;gt;&lt;/a&gt; !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-115886190309049409?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/115886190309049409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=115886190309049409' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115886190309049409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115886190309049409'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/09/scorpion-queen.html' title='Scorpion Queen !'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-115877973060170130</id><published>2006-09-20T12:11:00.000-07:00</published><updated>2006-09-20T12:26:52.363-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Connecting to URL from behind a proxy server</title><content type='html'>I needed a way to set the proxy information on URL/URLConnection and I could not find any good way. One simple way that java recommends is to set the information as system property. These properties are "http.proxyHost" and "http.proxyPort". &lt;br /&gt;&lt;br /&gt;So it can either be set as jvm arguments like &lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;-DproxySet=true -Dhttp.proxyHost=proxyIP -DproxyPort=port&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;or set them in the code using System.setProperty()&lt;br /&gt;&lt;br /&gt;However since this is a system property, it gets set on the VM itself and hence it is not dynamic. In ColdFusion, since tags like 'cfhttp' keep them dynamic, I wanted a similar behaviour. After looking around for a while, I noticed that this capability was added in Java 1.5 aka Tiger release. (Is it only me? I keep hitting things which I feel is lacking in java API and then I find them added in 1.5 :) )&lt;br /&gt;&lt;br /&gt;In Java 1.5, you can use &lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;URLConnection conn = url.openConnection(proxy); // added in 1.5&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;where proxy is an object of &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Proxy.html"&gt;java.net.Proxy&lt;/a&gt;. Pretty neat.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However this was not a solution for me as we are still developing on JDK1.4 (need to consider all the application servers that we have to  support). I stumbled upon an interesting article by &lt;a href="http://bdn.borland.com/article/0,1410,29783,00.html"&gt;Daniel Horn&lt;/a&gt; who faced the exact same problem. And guess what he did? Since you send an HTTP request to the proxy and then proxy sends out the actual request, he created the URL object by passing proxyHost and proxyPort as IP and port and then he gave the target url string as 'file' argument. This is what he did.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;String actualUrl = "http://www.adobe.com";&lt;br /&gt;URL url = new URL("http", proxyHost, proxyPort, actualUrl);&lt;br /&gt;URLConnection conn = url.openConnection();&lt;br /&gt;..&lt;br /&gt;..&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;And it works ! Brilliant !! I wonder why this is not documented in the java API.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-115877973060170130?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/115877973060170130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=115877973060170130' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115877973060170130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115877973060170130'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/09/connecting-to-url-from-behind-proxy.html' title='Connecting to URL from behind a proxy server'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-115869252935348183</id><published>2006-09-19T11:57:00.000-07:00</published><updated>2006-09-19T12:02:09.356-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>A workaround for cfdocument missing images</title><content type='html'>This is with reference to the post &lt;a href="http://coldfused.blogspot.com/2005/11/missing-images-in-cfdocument.html"&gt;Missing images in CFDocument&lt;/a&gt;. There are some cases when the images are locally on the machine running ColdFusion but even then cfdocument is not able to show the images. The reasons could be&lt;br /&gt;1) ColdFusion is behind a firewall because of which it is not able to send any HTTP request (even though to itself).&lt;br /&gt;2) The images are under a protected directory which needs authentication. Since cfdocument can not send authentication information currently, it is not able to fetch the image.&lt;br /&gt;3) ColdFusion is using HTTPS and it is not configured properly to trust itself. So cfdocument can not send a https request to itself.&lt;br /&gt;4) Any other reason which is preventing CFDocument from sending request to the local server.&lt;br /&gt;&lt;br /&gt;If the images are on local machine, it is possible to use the file url for images (or CSS,javascripts, etc). CFDocument in that case will not send requests for the images over HTTP and fetch the image directly from the file system. Here is a simple way to use the file url. &lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;cfdocument format="pdf"&amp;gt;&lt;br /&gt; &amp;lt;cfoutput&amp;gt;&lt;br /&gt;   Some html content&lt;br /&gt;   &amp;lt;br&amp;gt;&lt;br /&gt;   &amp;lt;img src=#localUrl("img1.gif")#&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;   &amp;lt;img src=#localUrl("images/img.jpg")#&amp;gt;&lt;br /&gt; &amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&amp;lt;/cfdocument&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cffunction name="localUrl" &amp;gt;&lt;br /&gt;  &amp;lt;cfargument name="file" /&amp;gt;&lt;br /&gt;  &amp;lt;cfset var fpath = ExpandPath(file)&amp;gt;&lt;br /&gt;  &amp;lt;cfset var f=""&amp;gt;&lt;br /&gt;  &amp;lt;cfset f = createObject("java", "java.io.File")&amp;gt;&lt;br /&gt;  &amp;lt;cfset f.init(fpath)&amp;gt;&lt;br /&gt;  &amp;lt;cfreturn f.toUrl().toString()&amp;gt;&lt;br /&gt;&amp;lt;/cffunction&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;basically here I have an UDF which converts any path to local URL and then I am using that UDF in 'src' attribute of image. This can be used to fetch images, css or any other similar contents from the local machine. You should note the &amp;lt;cfoutput&amp;gt; right under cfdocumet tag that allows the evaluation of UDF before it goes to cfdocument body.. This workaround is applicable only when the these contents are present on the same machine as ColdFusion. &lt;br /&gt;&lt;br /&gt;This workaround has another advantage too. Normally when CFDocument body has any images, it fetches those images by sending HTTP request to the local server which is served by web threads. This has its own overhead. In a way, CFDocument uses server resource for getting something which is available locally on the server. This resource can instead be used to serve actual client http requests. Converting the image path to local urls will not go through  HTTP and thus should have a better performance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-115869252935348183?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/115869252935348183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=115869252935348183' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115869252935348183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115869252935348183'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/09/workaround-for-cfdocument-missing_19.html' title='A workaround for cfdocument missing images'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-115833781342566408</id><published>2006-09-15T09:12:00.000-07:00</published><updated>2006-09-19T07:35:55.520-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><title type='text'>Update to CFThread POC tags</title><content type='html'>Damon posted an &lt;a href="http://www.dcooper.org/blog/client/index.cfm?mode=entry&amp;entry=A71F310C-4E22-1671-5E287AE8918A048B"&gt;update to the CFThread proof of concept tag&lt;/a&gt; that was published &lt;a href="http://www.dcooper.org/blog/client/index.cfm?mode=entry&amp;amp;entry=916FEFD9-4E22-1671-57A23859C50FFF47"&gt;some time back&lt;/a&gt;. I wanted to do it for a long time but was busy in other Scorpio features and had to keep delaying this. Neverthless better late than never :) This update includes "thread safety" while retaining the old syntax in the original post. Thanks to Dan Switzer, Derek, Mike and all others who provided the valuable feedback on it !&lt;br /&gt;&lt;br /&gt;Whats there in the update&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Thread very much acts like a function and some time little more than that.&lt;/li&gt;&lt;li&gt;Any attribute can be passed to cfthread. These attributes can be accessed using 'attributes.&amp;lt;varname&amp;gt;'. These attributes are passed by value and hence they are completely thread safe.&lt;/li&gt;&lt;li&gt;Any variable unless defined with a scope prefix goes in thread local scope. So this is slightly different from function. Like function, variable defined in var scope will also go in thread local scope. So in following snippet, x, y, z and a all will be in thread local scope. However since b is directly used inside thread without defining it, it will use it from the page scope.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;cfset x = 10&amp;gt;&lt;br /&gt;&amp;lt;cfset b = 20&amp;gt;&lt;br /&gt;&amp;lt;cfthread name="t1"&amp;gt;&lt;br /&gt; &amp;lt;cfset var y = 10&amp;gt;&lt;br /&gt; &amp;lt;cfset x = 20&amp;gt;&lt;br /&gt; &amp;lt;cfset z = y*x&amp;gt;&lt;br /&gt; ...&lt;br /&gt; &amp;lt;cfset a = z*Variables.x&amp;gt;&lt;br /&gt; &amp;lt;cfset a = a/b&amp;gt;&lt;br /&gt;&amp;lt;/cfthread&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;All other scope variables will be accessible using the appropriate prefix like "Variables", "request", "Server" etc.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Threads have an another scope called thread scope in which only the owner thread can write but all other can read. This scope can be accessed using 'thread' prefix by owner thread or using the thread name by other thread or main page thread. This scope will be useful when the owner thread wants to put some data in it which needs to accessed by other thread. The same thing could have been achieved by all the threads writing to the page scope in its own variable but that needs some discipline from developers and is error prone. Having a separate thread scope which other can read makes it threadsafe and easier for developers.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;If thread name is dynamic, it will be everyone's question how to access that thread data from another thread or main page. It can be easily done using &lt;span style="font-family:courier new;"&gt;Variables[threadname].xxx&lt;/span&gt;. See the example below.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Threads can continue even after the main page is done.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Below is a sample cf code that uses cfthread. (modified version of Dan's example. Thanks Dan !!).&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;cfset CRLF = CHR(13) &amp; CHR(10)&amp;gt;&lt;br /&gt;&amp;lt;cfset sDirectory = expandPath(".") &amp; "\tmp" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cfsavecontent variable="sContent"&amp;gt;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX &amp;lt;/cfsavecontent&amp;gt;&lt;br /&gt;&amp;lt;cfloop index="loopcounter" from="1" to="50"&amp;gt;&lt;br /&gt;&amp;lt;cfset threadname = "thread_" &amp; #loopcounter#&amp;gt;&lt;br /&gt;&amp;lt;cfthread name="#threadname#" filename="file#loopcounter#.txt" counter="#loopcounter#"&amp;gt;&lt;br /&gt;&amp;lt;cfset sOutput = "Content written by thread " &amp; #attributes.counter#&amp;gt;&lt;br /&gt;&amp;lt;cfloop index="i" from="1" to="100"&amp;gt;&lt;br /&gt;   &amp;lt;cfset sOutput = sOutput &amp; sContent&amp;gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&amp;lt;cfset sOutput&amp;gt;&lt;br /&gt;&amp;lt;cfset dest="#sDirectory#\tmp_#attributes.filename#"&amp;gt;&lt;br /&gt;&amp;lt;cffile action="write" file="#dest#" output="#sOutput#" /&amp;gt;&lt;br /&gt;&amp;lt;cfset thread.msg="Message from thread "&amp;#attributes.counter#&amp;gt;&lt;br /&gt;&amp;lt;/cfthread&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&amp;lt;cfloop index="loopcounter" from="1" to="50"&amp;gt;&lt;br /&gt;&amp;lt;cfset threadname = "thread_" &amp; #loopcounter#&amp;gt;&lt;br /&gt;&amp;lt;cfjoin thread="#threadname#"/&amp;gt;&lt;br /&gt;&amp;lt;cfoutput&amp;gt;&amp;lt;br&amp;gt;#threadname# output : #Variables[threadname].msg#&amp;lt;/cfoutput&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/cfloop&amp;gt;&lt;br /&gt;&amp;lt;br&amp;gt; Work Complete!&amp;lt;br&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Feel free to play around with this tag and send feedbacks if you have any. Once again, as Damon said, this is not a CF feature and hence it is unsupported. On whether it will make it to the Scorpio or not, I can not guarantee anything but stay tuned ;)&lt;br /&gt;Enjoy !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-115833781342566408?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/115833781342566408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=115833781342566408' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115833781342566408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115833781342566408'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/09/update-to-cfthread-poc-tags.html' title='Update to CFThread POC tags'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-115808816091974317</id><published>2006-09-12T11:59:00.001-07:00</published><updated>2006-09-15T00:15:34.476-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Handling J2EE session with cookies disabled</title><content type='html'>Someone recently reported that when cookies are disabled and J2EE session is enabled, his sessions are not maintained in case of POST request. As per that, CF or rather the app server always creates a new session everytime. His code looked like&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt; &amp;lt;form method="post" action="test.cfm?#session.urltoken#"&amp;gt;&lt;br /&gt;    ...&lt;br /&gt;   &amp;lt;input type="submit" value="Submit" &amp;gt;&lt;br /&gt; &amp;lt;/form&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;can you see whats wrong with above code?&lt;br /&gt;&lt;br /&gt;As per the Servlet spec of J2EE, when cookies are disabled, session is maintained by url rewriting and that is done by appending ';jsessionid=&lt;sessionid&gt;' to the URI. Note the semicolon ';' before 'jsessionid'.&lt;br /&gt;&lt;br /&gt;In the above code, it is appending session.urltoken which looks like 'CFID=1600&amp;CFTOKEN=59663989&amp;amp;jsessionid=2830a9edcf6f794ff481'. Therefore the url becomes "test.cfm?CFID=1600&amp;CFTOKEN=59663989&amp;amp;jsessionid=2830a9edcf6f794ff481" whereas it should been like "test.cfm;jsessionid=2830a9edcf6f794ff481?CFID=1600&amp;CFTOKEN=59663989". Since jsessionId is not correctly specified, server does not get this and hence creates a new session.&lt;br /&gt;&lt;br /&gt;So how do you handle it? One way is to get the sessionId and urltoken from the session and create the url as expected (which is some effort on developer part). Alternatively, you can use a rather simple approach of using URLSessionFormat(url) which will do the exact thing which is required here. URLSessionFormat() appends the necessary information if cookies are disabled. If they are enabled, it does not do anything. Therefore it might be a better idea to always use this function for any GET or POST url.&lt;br /&gt;&lt;br /&gt;The above code should actually have been&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt; &amp;lt;cfset myurl=URLSessionFormat("test.cfm")&amp;gt;&lt;br /&gt;   &amp;lt;form method="post" action="#myurl#"&amp;gt;&lt;br /&gt;    ...&lt;br /&gt;   &amp;lt;input type="submit" value="Submit" &amp;gt;&lt;br /&gt; &amp;lt;/form&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-115808816091974317?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/115808816091974317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=115808816091974317' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115808816091974317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115808816091974317'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/09/handling-j2ee-session-with-cookies_12.html' title='Handling J2EE session with cookies disabled'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-115807076165899719</id><published>2006-09-12T07:07:00.000-07:00</published><updated>2006-09-16T23:00:16.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='jrun'/><title type='text'>JRun Threadpool settings</title><content type='html'>The other day I was looking at JRun's Threadpool implementation and it really took me SOME time to understand that piece of code. It is one of those codes which are not meant to be understood by others :D. It got me really confused about 'Active Handler Threads', 'min Handler Threads' and 'max Handler threads'. It was very much different from what I had assumed. Too much of 'creating runnables', 'swapping runnables', 'destroying runnables'.. phew.. I think this is the exact reason why Doug Lea and team had to introduce a standard implementation of ThreadPool in 'Tiger' release. Its so simple, neat and elegant I wonder why wasn't it introduced earlier in JDK.&lt;br /&gt;&lt;br /&gt;Anyways, enough of cribbing. After my enlightenment of JRun's or CFMX's threadpool, I thought it would be nice to share it with you all. So what are these thread counts? (I am sure most of you would have it figured out. Neverthless.. :) )&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Min handler threads&lt;/span&gt; - It is the number of web threads that will be spawned initially and will be waiting for HTTP requests. Which effectively means that it is the no of threads which will be waiting on &lt;span style="font-family: courier new;"&gt;serversocket.accept()&lt;/span&gt;. Thus it controls the no of requests that will be accepted concurrently. It is ideally the minimum concurrent users that you expect on the server. As soon as a thread gets a client request (i.e comes out of serversocket.accept()), it enters into a throttle before processing the request. This is where active handler threads come into the picture. Before the thread starts processing the request, it spawns another thread, if required, which can listen to the incoming requests. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Active handler threads&lt;/span&gt; - This decides how many requests would be concurrently processed. The throttle we talked about above, allows a maximum of "active handler" threads to continue and rest of threads wait until another thread exits the throttle. This along with "min handler thread" controls the throughput of the server. The value of active handler threads must be between min Handler count and maxHandler Count.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Max handler threads&lt;/span&gt; - This is maximum number of threads that can be created in the pool. This includes the threads queued in the throttle + threads processing the requests + threads waiting on the server socket. Once the server reaches the max Handler thread count, server will start denying the request throwing "Server Busy Error". You can see the "Server Busy" error even without server reaching the "max handler" limit if the thread in the throttle queue timeout. So if you see this error, dont start increasing the max handler thread count. You might need to tune all the three counts.&lt;br /&gt;&lt;br /&gt;Having both MinHandler and activeHandler counts help JRun in addressing any sudden spike in the load. Lets say your minHandler count is 20 and activeHandler count is 40 and suddenly you have 40 concurrent requests, all of them will be served without any queuing and delay. When the load eases down on the server, it will let the extra threads die and bring the thread count down to minhandler count i.e 20.&lt;br /&gt;&lt;br /&gt;The next question that naturally comes to the mind is what should be the appropriate values of these for my server? Having too less value for it would mean that you are not utilizing the potential of the server well and requests start queuing up even though server can handle it. Having a too high value for these would mean too many context switches and the server performance will deteriorate. (Too many context switches means CPU is busy scheduling the threads rather than executing them and thus hurts the performance) So what should be the appropriate value? well.. there can not be one answer or a formula to compute these values. It depends on your application, the traffic that your application expects, memory and processors of the machine on which you are going to run it etc etc.&lt;br /&gt;&lt;br /&gt;By default the values in "ColdFusion standalone" are&lt;br /&gt;&lt;br /&gt;- Min Handler Thread - 1&lt;br /&gt;- Active Handler Thread - 8&lt;br /&gt;- max Handler thread - 1000&lt;br /&gt;&lt;br /&gt;min and active counts here are fine for a development machine but definitely not for a production machine. And in my opinion the value of 'max handler' is bit high even for a production machine. Creating a large no of threads does not necessarily increases the throughput of your server. It can actually lower it down because of the high no of context switches VM will have to make. Moreover, it might not be possible to create 1000's of threads because of OS limitations. On many of the OS, you will get an OutOfMemory Error because the VM will not be able to spawn so many native threads for you. I think max handler count in the range of 300-400 should be good enough.&lt;br /&gt;&lt;br /&gt;Regarding tuning these counts, there are huge no of articles around which will tell you how to go about it. Since notion of these counts exist on all the application/web servers, articles need not be CF or JRun specific. In brief, you would need to run some kind of load tests with different values of minHandler and active handler counts, note the throughput and plot a graph. This graph should help you arrive at the appropriate value for these settings.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-115807076165899719?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/115807076165899719/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=115807076165899719' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115807076165899719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115807076165899719'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/09/jrun-threadpool-settings.html' title='JRun Threadpool settings'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-115342492768590072</id><published>2006-07-20T12:36:00.000-07:00</published><updated>2006-09-12T07:07:19.580-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='jrun'/><title type='text'>Weird Error while JRun/CF Startup</title><content type='html'>&lt;span style=";font-family:georgia;font-size:100%;"  &gt;Today suddenly one of the test machine here started to give one weird error. It had Coldfusion standalone and the CF server would not start up. I checked up all the logs and there was nothing in it. In fact JRun process itself didnt start up.&lt;br /&gt;When I tried to run it from the console using "jrun -start coldfusion", I saw the following error laughing at me.&lt;br /&gt;&lt;/span&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;Exception in thread "main" java.lang.ExceptionInInitializerError&lt;br /&gt;Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission jrun.home read)&lt;br /&gt; at java.security.AccessControlContext.checkPermission(Unknown Source)&lt;br /&gt; at java.security.AccessController.checkPermission(Unknown Source)&lt;br /&gt; at java.lang.SecurityManager.checkPermission(Unknown Source)&lt;br /&gt; at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)&lt;br /&gt; at java.lang.System.getProperty(Unknown Source)&lt;br /&gt; at jrunx.kernel.JRun.&lt;clinit&gt;(JRun.java:52)&lt;br /&gt;&lt;/clinit&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;It was spooky as I could see that the policy file has all permission and the JVM was complaining that the JRun process does not have the permission to read jrun.home property.&lt;br /&gt;I was going bonkers before I realized that policy file was not getting picked up in the first place.&lt;br /&gt;Finally it turned out that some test setup had messed around with the jvm.config file and misplaced some quotes. java.args in this file looked like&lt;br /&gt;&lt;/span&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;java.args=-server -XX:MaxPermSize=128m -Xmx512m -Dsun.io.useCanonCaches=false&lt;br /&gt;-Dcoldfusion.classPath={application.home}/../lib/updates,{application.home}/../lib/,{application.home}/../gateway/lib/,{application.home}/../wwwroot/WEB-INF/cfform/jars&lt;br /&gt;-Dcoldfusion.libPath={application.home}/../lib&lt;br /&gt;-Dcoldfusion.rootDir={application.home}/../ -Djava.security.manager&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;-Djava.security.policy="C:/CF/lib/coldfusion.policy"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;-Djava.security.auth.policy="C:/CF/lib/neo_jaas.policy"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;where it should have been like&lt;br /&gt;&lt;/span&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;java.args=-server -XX:MaxPermSize=128m -Xmx512m -Dsun.io.useCanonCaches=false&lt;br /&gt;-Dcoldfusion.classPath={application.home}/../lib/updates,{application.home}/../lib/,{application.home}/../gateway/lib/,{application.home}/../wwwroot/WEB-INF/cfform/jars&lt;br /&gt;-Dcoldfusion.libPath={application.home}/../lib&lt;br /&gt;-Dcoldfusion.rootDir={application.home}/../ -Djava.security.manager&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204); font-weight: bold;"&gt;"-Djava.security.policy=C:/CF/lib/coldfusion.policy"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(102, 102, 204);"&gt;"-Djava.security.auth.policy=C:/CF/lib/neo_jaas.policy"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;So in case you are touching jvm.config file (Ideally you should not), take extra care about the quotes.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-115342492768590072?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/115342492768590072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=115342492768590072' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115342492768590072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/115342492768590072'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/07/weird-error-while-jruncf-startup.html' title='Weird Error while JRun/CF Startup'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-114675758322001792</id><published>2006-05-04T08:40:00.000-07:00</published><updated>2006-05-04T22:58:39.433-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><title type='text'>Hotfix for CFDocument thread hang in CF7.0.1 standard.</title><content type='html'>There was a problem in CF7.0.1 standard edition where if you hit any error in a page using CFDocument, any other page using cfdocument will hang. This was a threading issue we had for standard edition and was logged as bug 61378.&lt;br /&gt;&lt;br /&gt;This was fixed in the hotfix 1 and is available at &lt;br /&gt;http://www.adobe.com/support/coldfusion/ts/documents/aae43964/chf7010001.jar&lt;br /&gt;&lt;br /&gt;However I would recommend you to use hotfix 2 at&lt;br /&gt;http://www.adobe.com/support/coldfusion/ts/documents/aae43964/chf7010002.jar&lt;br /&gt;See the details of this hotfix at http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=aae43964&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-114675758322001792?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/114675758322001792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=114675758322001792' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/114675758322001792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/114675758322001792'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/05/hotfix-for-cfdocument-thread-hang-in.html' title='Hotfix for CFDocument thread hang in CF7.0.1 standard.'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-114675189377948070</id><published>2006-05-04T07:04:00.000-07:00</published><updated>2006-09-13T13:08:10.250-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><title type='text'>Scale to fit for CFDocument</title><content type='html'>I have seen couple of posts on the forum in which people wanted to know a way to fit the document in a page. I am wondering about the use case if this is really required. Could you please let me know the use cases and how are you working around it currently. You need to build a case to get this attribute in the tag :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-114675189377948070?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/114675189377948070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=114675189377948070' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/114675189377948070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/114675189377948070'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2006/05/scale-to-fit-for-cfdocument.html' title='Scale to fit for CFDocument'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-113283507711053452</id><published>2005-11-24T04:18:00.000-08:00</published><updated>2005-11-24T04:37:42.303-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Host name verification in HTTPS</title><content type='html'>As I mentioned in my blog on &lt;a href="http://coldfused.blogspot.com/2005/11/missing-images-in-cfdocument.html"&gt;Missing images in CFDocument&lt;/a&gt;, in case you are using HTTPS, you must ensure that the certicate host name matches the host name in the URL. Lets say your certificate is issued to "www.mysite.com" then the request URL must have the host as "www.mysite.com". It can not be accessed using 'localhost', '127.0.0.1', that machine's IP address or machine's name.&lt;br /&gt;Till JDK1.3, Sun's SSL implementation never used to verify the host name of the certificate. Since JDK1.4, it now verifies the hostname to prevent URL spoofing (When I request for some URL, some other guy in between intercepts and sends his own certificate and I will remain under the impression that I was getting the certificate of the requested server and hence a threat).&lt;br /&gt;&lt;br /&gt;In case you want to access the URL using localhost or IP address or using machine's name, there is a workaround possible but that would invlove wrting some java code.&lt;br /&gt;&lt;code&gt;HttpsURLConnection&lt;/code&gt; that is used to make the connection, uses an interface &lt;code&gt;HostnameVerifier&lt;/code&gt; to verify the host name of the certificate. A default implementation is used by default. You can provide your own implementation of this interface and set it on HttpsURLConnection. That will give the control of host name verification in your hand and you can verifiy it the way you want.&lt;br /&gt;&lt;br /&gt;Unfortunately, this interface and &lt;code&gt;HttpsURLConnection&lt;/code&gt; are present in both &lt;code&gt;javax.net.ssl&lt;/code&gt; and &lt;code&gt;com.sun.net.ssl&lt;/code&gt; package. So depending on which SSL packages are being used, you will have to implement appropriate interface and you will have to set this on appropriate HttpsURLConnection. To be sure, let your implementation class implement both the interface and set it on both the &lt;code&gt;HttpsURLConnection&lt;/code&gt; by calling the static method&lt;pre&gt;setDefaultHostnameVerifier(HostnameVerifier)&lt;/pre&gt;&lt;br /&gt;A simplistic implementation which disables any host name verification could be like&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    class MyHostnameVerifier implements com.sun.net.ssl.HostnameVerifier, javax.net.ssl.HostnameVerifier{&lt;br /&gt;        public boolean verify(String urlHostName, String certHostName){&lt;br /&gt;            return true;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public boolean verify(String urlHost, SSLSession sslSession){&lt;br /&gt;            return true;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;set this verifier to both HttpsURLConnection at appropriate place.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    MyHostnameVerifier verifier = new MyHostnameVerifier();&lt;br /&gt;    javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(verifier);&lt;br /&gt;    com.sun.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(verifier);&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-113283507711053452?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/113283507711053452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=113283507711053452' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/113283507711053452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/113283507711053452'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2005/11/host-name-verification-in-https.html' title='Host name verification in HTTPS'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-113282380074031610</id><published>2005-11-24T00:55:00.000-08:00</published><updated>2005-11-24T04:46:16.973-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>Thread dumps...</title><content type='html'>Many a times our customers complain of Coldfusion Server(CF) hanging, becoming non-responsive, taking 100% cpu or some request taking too much time. In order to understand the reasons why this happens, only way is to analyze the "Thread dumps". Not many of our CF users are java geeks and therefore when we ask them to send a thread dump, they have a very little clue about it. I hope they wouldn't be clueless anymore ;)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;What exactly is "Thread dump"&lt;/span&gt;&lt;br /&gt;"Thread dump" basically gives you information on what each of the thread in the VM is doing at any given point of time. This makes "Thread dump" an excellent debugging tool. It can tell you the states of each of the thread in the VM, where exactly each thread is in the execution path at that point, which thread is waiting and where is it waiting and lot more. It also shows you the stack of each thread and can help you track the execution path.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;How do I take a Thread dump?&lt;/span&gt;&lt;br /&gt;For any Java VM, if you are running it from a command prompt, you can get the thread dump by pressing &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Break&lt;/kbd&gt; (for windows) or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;\&lt;/kbd&gt; (for unix machines) on the terminal running the server.&lt;br /&gt;In case you are running the VM in background or as services, you can send a "SIGQUIT" signal to the process to get the thread dump. To send this signal to VM on unix machine, you can use "kill -SIGQUIT [pid]" where 'pid' is the process id of the server process. This will send the signal to the VM to dump the thread stack on the error stream (On Sun JVM) or to a new file (IBM's JVM).&lt;br /&gt;&lt;br /&gt;You can also use the &lt;a href="http://tmitevski.users.mcs2.netarray.com/stacktrace/app/launch.jnlp"&gt;Stacktrace tool&lt;/a&gt; to get the thread dump. It is a nice java webstart application that you can run on the machine running the server. All you need is to specify the "process id" and it will nicely show the threaddump in its own window.&lt;br /&gt;&lt;br /&gt;To be more specific for CF, if the standalone CF server or CF on J2EE server has a terminal, use &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Break&lt;/kbd&gt; or &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;\&lt;/kbd&gt; depending on the platform. If its running as background process or as services, use Stacktrace tool I mentioned earlier.&lt;br /&gt;&lt;br /&gt;Here is how the thread dump would look.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Full thread dump Java HotSpot(TM) Server VM (1.5.0_04-b05 mixed mode):&lt;br /&gt;&lt;br /&gt;"web-4" prio=5 tid=0x28999418 nid=0x1460 runnable [0x2fbaf000..0x2fbafd18]&lt;br /&gt;       at java.io.WinNTFileSystem.canonicalize0(Native Method)&lt;br /&gt;       at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:374)&lt;br /&gt;       at java.io.File.getCanonicalPath(File.java:531)&lt;br /&gt;       at java.io.FilePermission$1.run(FilePermission.java:218)&lt;br /&gt;       at java.security.AccessController.doPrivileged(Native Method)&lt;br /&gt;       at java.io.FilePermission.init(FilePermission.java:212)&lt;br /&gt;       at java.io.FilePermission.&lt;init&gt;(FilePermission.java:264)&lt;br /&gt;       at java.lang.SecurityManager.checkRead(SecurityManager.java:871)&lt;br /&gt;       at java.io.File.exists(File.java:700)&lt;br /&gt;       at jrunx.resource.FileResource.exists(FileResource.java:98)&lt;br /&gt;       at jrunx.resource.FileResource.getURL(FileResource.java:140)&lt;br /&gt;       at jrun.servlet.JRunServletContext.getResource(JRunServletContext.java:192)&lt;br /&gt;       at jrun.servlet.file.FileServlet.service(FileServlet.java:148)&lt;br /&gt;       at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)&lt;br /&gt;       at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)&lt;br /&gt;       at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)&lt;br /&gt;       at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)&lt;br /&gt;       at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)&lt;br /&gt;       at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)&lt;br /&gt;&lt;br /&gt;"web-3" prio=5 tid=0x2814e470 nid=0xd70 in Object.wait() [0x2faaf000..0x2faafd98]&lt;br /&gt;       at java.lang.Object.wait(Native Method)&lt;br /&gt;       - waiting on &lt;0x064b5a90&gt; (a jrunx.scheduler.JSemaphore)&lt;br /&gt;       at jrunx.scheduler.JSemaphore.acquire(JSemaphore.java:74)&lt;br /&gt;       - locked &lt;0x064b5a90&gt; (a jrunx.scheduler.JSemaphore)&lt;br /&gt;       at jrun.servlet.network.NetworkService.accept(NetworkService.java:348)&lt;br /&gt;       at jrun.servlet.http.WebService.createRunnable(WebService.java:104)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$DownstreamMetrics.createRunnable(ThreadPool.java:285)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$ThreadThrottle.createRunnable(ThreadPool.java:347)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$UpstreamMetrics.createRunnable(ThreadPool.java:239)&lt;br /&gt;       at jrunx.scheduler.WorkerThread.run(WorkerThread.java:62)&lt;br /&gt;&lt;br /&gt;"web-2" prio=5 tid=0x271954c0 nid=0x170c in Object.wait() [0x2ef6e000..0x2ef6fa18]&lt;br /&gt;       at java.lang.Object.wait(Native Method)&lt;br /&gt;       - waiting on &lt;0x02af8eb8&gt; (a java.awt.image.PixelGrabber)&lt;br /&gt;       at java.awt.image.PixelGrabber.grabPixels(PixelGrabber.java:254)&lt;br /&gt;       - locked &lt;0x02af8eb8&gt; (a java.awt.image.PixelGrabber)&lt;br /&gt;       at java.awt.image.PixelGrabber.grabPixels(PixelGrabber.java:209)&lt;br /&gt;       at com.lowagie.text.Image.getInstance(Unknown Source)&lt;br /&gt;       at com.lowagie.text.Image.getInstance(Unknown Source)&lt;br /&gt;       at com.lowagie.text.pdf.PdfGraphics2D.addAltText(Unknown Source)&lt;br /&gt;       at ice.pilots.html4.MacromediaCSSExtension.addonImageProcessing(MacromediaCSSExtension.java:186)&lt;br /&gt;       at ice.pilots.html4.ObjectBox.paintChunk(OEAB)&lt;br /&gt;       at ice.pilots.html4.InlineBox.paintChildren(OEAB)&lt;br /&gt;       at ice.pilots.html4.InlineBox.paintChunk(OEAB)&lt;br /&gt;       at ice.pilots.html4.InlineBox.paintChildren(OEAB)&lt;br /&gt;       at ice.pilots.html4.BlockBox.paint(OEAB)&lt;br /&gt;       at ice.pilots.html4.OutlinePainter.drawBox(OEAB)&lt;br /&gt;       at ice.pilots.html4.BlockBox.paint(OEAB)&lt;br /&gt;       at ice.pilots.html4.OutlinePainter.drawBox(OEAB)&lt;br /&gt;       at ice.pilots.html4.BlockBox.paint(OEAB)&lt;br /&gt;       at ice.pilots.html4.CSSLayout.paint(OEAB)&lt;br /&gt;       - locked &lt;0x02cebb10&gt; (a java.lang.Object)&lt;br /&gt;       at ice.pilots.html4.ThePrinter.printPage(Unknown Source)&lt;br /&gt;       at coldfusion.document.DocumentSection.process(DocumentSection.java:230)&lt;br /&gt;       at coldfusion.document.DocumentSection.print(DocumentSection.java:108)&lt;br /&gt;       at coldfusion.document.DocumentExporter.export(DocumentExporter.java:237)&lt;br /&gt;       at coldfusion.document.DocumentFrame.exportContent(DocumentFrame.java:118)&lt;br /&gt;       at coldfusion.document.DocumentProcessor.processContent(DocumentProcessor.java:130)&lt;br /&gt;       at coldfusion.document.DocumentProcessor.ProcessContent(DocumentProcessor.java:59)&lt;br /&gt;       at coldfusion.tagext.lang.DocumentTag.processContent(DocumentTag.java:1218)&lt;br /&gt;       at coldfusion.tagext.lang.DocumentTag.access$100(DocumentTag.java:84)&lt;br /&gt;       at coldfusion.tagext.lang.DocumentTag$3.run(DocumentTag.java:1179)&lt;br /&gt;       at java.security.AccessController.doPrivileged(Native Method)&lt;br /&gt;       at coldfusion.tagext.lang.DocumentTag.doAfterBody(DocumentTag.java:1174)&lt;br /&gt;       at cfcmyk2ecfm937582361.runPage(E:\CFusionMX7\wwwroot\testfolder\doctest\cmyk.cfm:3)&lt;br /&gt;       at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)&lt;br /&gt;       at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)&lt;br /&gt;       at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)&lt;br /&gt;       at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:209)&lt;br /&gt;       at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:51)&lt;br /&gt;       at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)&lt;br /&gt;       at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:69)&lt;br /&gt;       at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)&lt;br /&gt;       at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)&lt;br /&gt;       at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)&lt;br /&gt;       at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)&lt;br /&gt;       at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115)&lt;br /&gt;       at coldfusion.CfmServlet.service(CfmServlet.java:107)&lt;br /&gt;       at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)&lt;br /&gt;       at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)&lt;br /&gt;       at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)&lt;br /&gt;       at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)&lt;br /&gt;       at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)&lt;br /&gt;       at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)&lt;br /&gt;       at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)&lt;br /&gt;       at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;/init&gt;&lt;/pre&gt;&lt;br /&gt;If you anayze this thread dump, you can see that "web-2" thread is handling request for "cmyk.cfm" and is waiting for the images to be loaded i.e (actually at Image.getInstance()). At this point, cfdocument has sent another http request for the image file that it has to render and that request is handled by another thread "web-4" which is running and is currently checking if the image file requested exists on the file system. Isn't it very powerful ?&lt;br /&gt;&lt;br /&gt;You can checkout a very nice article &lt;a href="http://www.me.umn.edu/%7Eshivane/blogs/cafefeed/2004/06/of-thread-dumps-and-stack-traces.html"&gt;Thread dump and stack traces&lt;/a&gt; written by Rajiv (my ex-colleague and mentor in &lt;a href="www.pramati.com"&gt;Pramati&lt;/a&gt;) which I feel is a must read for Java developers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-113282380074031610?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/113282380074031610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=113282380074031610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/113282380074031610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/113282380074031610'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2005/11/thread-dumps.html' title='Thread dumps...'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19056005.post-113221665359743921</id><published>2005-11-17T00:31:00.000-08:00</published><updated>2007-08-21T11:13:24.545-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='coldfusion'/><category scheme='http://www.blogger.com/atom/ns#' term='cfdocument'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Missing images in CFDocument</title><content type='html'>I have seen huge no of postings on CF forum where CFDocument users have complained about seeing red-cross (or red-x &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/1031/809/1600/red-x.1.jpg"&gt;&lt;img style="cursor: pointer;" src="http://photos1.blogger.com/blogger/1031/809/200/red-x.1.jpg" alt="" border="0" /&gt;&lt;/a&gt;) for images . In this post, I would like to list the reasons why they happen and how they could be resolved .&lt;br /&gt;&lt;br /&gt;Before we proceed with different cases of red-x, lets see in brief, how images are rendered in CFDocument.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;During the processing of cfdocument tag, CF engine interprets/executes the content inside the cfdocument tag, creates html content out of it and renders it in the memory. While rendering this html content, if any image tag is found, a separate HTTP request is made to retrieve this image content. A separate HTTP request is necessary because image in the generated html can be local as well as remote. For Java geeks out there, we use &lt;span style="font-family:courier new;"&gt;URLConnection.getContent() &lt;/span&gt;to retrieve the image data. A red-x means that CFDocument was not able to retrieve the image.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now lets see different scenarios one by one&lt;br /&gt;&lt;ol&gt;   &lt;li&gt;&lt;span style="font-weight: bold;"&gt;Image name has space in it&lt;/span&gt;. In CFMX 7.0, you can get red-x for images if the image file name has any space in it. For example if the image file name is "my picture.jpg", only a red-x will appear in the pdf/flashpaper. It happens because the url created for the image is not encoded. A workaround for this is to either use encoded url for the images i.e replace 'space' in the name with '&lt;span style="font-family:courier new;"&gt;%20&lt;/span&gt;' OR dont have spaces in the file name at all :). This bug has been fixed in Merrimack (Coldfusion 7.0.1). So if you are still on 7.0, upgrade :)&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-weight: bold;"&gt;If your server is behind firewall&lt;/span&gt;. As we mentioned earlier, CF server needs to send an HTTP request for the images. If the firewall prevents any outgoing connection from the server, CF will not be able to retrieve them and will show a red-x in place of them. You will need to setup your firewall in such a way that server can send an HTTP request to itself.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-weight: bold;"&gt;If your server is behind a proxy&lt;/span&gt;. If Coldfusion server is connected to the external world using a proxy, then also CFDocument will not be able to load the images. This is because currently there is no way you can specify proxy configuration for CFDocument tag.&lt;br /&gt;Current solution to solve this is to define the following system properties for the JVM. You can specify these in "runtime/bin/jvm.config" if you are using standlone or on JRun server.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;-DproxySet=true  -DproxyHost=[hostname]&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; -DproxyPort=[port]&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; -Dhttp.proxyHost=&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;[hostname] -Dhttp.proxyPort=[port]&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;   &lt;li&gt;&lt;span style="font-weight: bold;"&gt;If you are using HTTPS&lt;/span&gt; and your images do not appear in the pdf/flashpaper, you must ensure the following&lt;/li&gt;   &lt;ul&gt;     &lt;li&gt;CF server's certificate is trusted. In other words, certificate of the CA who issued the certificate for you, must be present in the trusted certificate store (runtime/lib/trustStore). You can use &lt;a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/keytool.html"&gt;keytool&lt;/a&gt; to list/view/import/.. certificate in the certificate store.&lt;br /&gt;If CF is using a self signed certificate, CF's certificate must be present in the trustStore.&lt;/li&gt;   &lt;/ul&gt;   &lt;ul&gt;     &lt;li&gt;The certificate is valid and has not expired.&lt;/li&gt;   &lt;/ul&gt;   &lt;ul&gt;     &lt;li&gt;Host name of the server must match the host name to which the certificate was issued.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;   &lt;/ul&gt;   &lt;li&gt;&lt;span style="font-weight: bold;"&gt;If the resources on your webserver are protected&lt;/span&gt; using some kind of authentication like basic authentication or digest authentication, cfdocument can not retrieve those resources. That is because you can not provide any authentication information to cfdocument tag currently. This means that cfdocument can not retrieve images if it is protected using authentication and you will see a red-x. One solution for this is to replace all image urls with "file" urls. &lt;a href="http://coldfused.blogspot.com/2006/09/workaround-for-cfdocument-missing_19.html"&gt;&lt;br /&gt;See this entry&lt;/a&gt; for more details on this workaround. The other solution is to write little java code to set a '&lt;span style="font-family:courier new;"&gt;java.net.Authenticator&lt;/span&gt;'. I will post a separate entry for this.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You get red-x for images and you have verified that its none of the above mentioned cases. Time to check the web server now. We have seen some cases where the web server is configured to allow requests only from a certain set of browsers (User agents to be precise) perhaps to prevent spiders and bots from overloading the server. When CFDocument creates a URLConnection for the image, it sends a "User-Agent" header, that looks like "&lt;span style="font-family:courier new;"&gt;User-Agent:Java/1.4.2_07&lt;/span&gt;", in the HTTP request. If the web server does not recognize "Java" user-agent, it returns a status code of 404 (resource not found) and hence the images can not be displayed. Solution for this case is to either change the configration for the web server or set your own user agent using the following system property on the JVM.&lt;br /&gt;&lt;pre&gt;    -Dhttp.useragent="ColdFusion"&lt;br /&gt;&lt;/pre&gt;You can give any name here as userAgent in place of "ColdFusion".&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt; &lt;host&gt;&lt;port&gt;&lt;host&gt;&lt;port&gt;Hope this helps people in resolving isues related to missing images in CFDocument. &lt;/port&gt;&lt;/host&gt;&lt;/port&gt;&lt;/host&gt;&lt;host&gt;&lt;port&gt;&lt;host&gt;&lt;port&gt;In case you are getting a red-x even after verifying all the cases mentioned above, please let me know.&lt;br /&gt;&lt;br /&gt;Related Entry :&lt;br /&gt;&lt;/port&gt;&lt;/host&gt;&lt;/port&gt;&lt;/host&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://coldfused.blogspot.com/2006/09/workaround-for-cfdocument-missing_19.html"&gt;Workaround for cfdocument missing images&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://coldfused.blogspot.com/2007/02/accessing-password-protected-url_5016.html"&gt;Accessing password protected URL&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://coldfused.blogspot.com/2007/06/new-cfdocument-hotfix-released.html"&gt;New CFDocument Hotfix released&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://coldfused.blogspot.com/2007/07/enhancements-to-cfdocument-in.html"&gt;Enhancement to CFDocument in CF8&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19056005-113221665359743921?l=coldfused.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://coldfused.blogspot.com/feeds/113221665359743921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19056005&amp;postID=113221665359743921' title='33 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/113221665359743921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19056005/posts/default/113221665359743921'/><link rel='alternate' type='text/html' href='http://coldfused.blogspot.com/2005/11/missing-images-in-cfdocument.html' title='Missing images in CFDocument'/><author><name>Rupesh Kumar</name><uri>http://www.blogger.com/profile/11403172559407967918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>33</thr:total></entry></feed>
