Processing HTM and HTML files in ColdFusion 2016

Some of our clients are simply hosting ColdFusion sites on our servers. These sites are sometimes using HTML and HTM files as the source of ColdFusion code. In such a case, we have to configure ColdFusion to parse them the same way as CFM files.

I assume that the site is already pre-configured: the connector between the web server and ColdFusion is created so the CFM files are processed properly. Now we will only add the HTM and HTML processing.

There are three steps:

  1. On your website Handler Mappings, you will find *.cfm and *.cfc handlers. Click on one of them and select Edit – take a look at the path in the Executable field:

Now you should go to this folder and find the file named “uriworkermap.properties” – edit this file. Inside you will find various entries regarding cfc and cfm files:

At the end of the file add these two lines:

/*.html = cfusion
/*.htm = cfusion

2. The second step is to adjust the ColdFusion mappings. In your ColdFusion installation directory, find “\cfusion\wwwroot\WEB-INF\web.xml” file. Inside the file, search for “coldfusion_mapping_1”. You will see the long list of ColdFusion mappings. Take a look what is the last number used. Then, after the last one, add the following lines:

        <servlet-mapping id="coldfusion_mapping_32">
		<servlet-name>CfmServlet</servlet-name>
		<url-pattern>*.htm</url-pattern>
	</servlet-mapping>
	<servlet-mapping id="coldfusion_mapping_33">
		<servlet-name>CfmServlet</servlet-name>
		<url-pattern>*.htm/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping id="coldfusion_mapping_34">
		<servlet-name>CfmServlet</servlet-name>
		<url-pattern>*.html</url-pattern>
	</servlet-mapping>
	<servlet-mapping id="coldfusion_mapping_35">
		<servlet-name>CfmServlet</servlet-name>
		<url-pattern>*.html/*</url-pattern>
	</servlet-mapping>

In my case, I used the numbers of 32-35. It can be different for you. Just increment the last number you found on the mappings above.

3. The last step is to go to the Services and restart the ColdFusion Application service. Now your HTML and HTM files should be processed by ColdFusion.

Please note that you can use the same way to process also other types of files, but I strongly suggest sticking with the default CFM and CFC while developing ColdFusion websites.

Leave a Reply

Your email address will not be published. Required fields are marked *