Processing HTML, HTM (or other) files in ColdFusion 10

ColdFusion , Default , Web Development Add comments

I was recently working on a legacy ColdFusion application that required .html and .htm files to be processed with ColdFusion.  The application currently runs on ColdFusion 9 and we are preparing it for ColdFusion 10.  To accomplish the processing of .html files with ColdFusion, we had always followed the method of editing the web.xml file and adjusting the ISAPI filter in IIS.  However, this was not enough in ColdFusion 10.  In CF10, there is now an additional step that is required due to TomCat.

Steps to set this up...

  1. Set up IIS and the connectors as previously documented.  Instructions from Peter Bell
  2. Go to the uriworkermap.properties file for your ColdFusion10 install
    • The normal path to this is <cf root>/config/wsconfig/1/uriworkermap.properties
  3. Copy the line /*.cfm = cfusion and create new lines at the bottom of the file as follows for each extension you want ColdFusion to process.

    /*.html = cfusion
    /*.htm = cfusion 
  4. Save uriworkermap.properties and restart your ColdFusion 10 service.

 

17 responses to “Processing HTML, HTM (or other) files in ColdFusion 10”

  1. Ryan Jones Says:
    Thank you for this! This was the only reference I could find on the web regarding this change due to TomCat.
  2. Andrew Hargreaves Says:
    Yes thanks for posting this info -- it helped me get my server working properly. Appreciated.
  3. Steven Benn Says:
    Nice tips.I think this steps will help to those who is involved in ColdFusion application & running several test via this application. This steps will really help for the newbies who is basically deal with the app development.
  4. Jeff Says:
    I know it's been a while since this blog entry was posted but I am seeing this message in the cf error log several times a day.

    Oct 25, 2013 7:12:43 AM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet [CfmServlet] in context with path [/] threw exception [ROOT CAUSE:
    java.lang.NullPointerException
    ] with root cause
    javax.servlet.ServletException: ROOT CAUSE:
    java.lang.NullPointerException

       at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:70)
       at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
       at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414)
       at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:204)
       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
       at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
       at java.lang.Thread.run(Thread.java:724)

    I have this is the web.xml

    <servlet-mapping id="coldfusion_mapping_16">
    <servlet-name>CfmServlet</servlet-name>
    <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    <servlet-mapping id="coldfusion_mapping_17">
    <servlet-name>CfmServlet</servlet-name>
    <url-pattern>*.htm/*</url-pattern>
    </servlet-mapping>
       <servlet-mapping id="coldfusion_mapping_18">
    <servlet-name>CfmServlet</servlet-name>
    <url-pattern>*.html</url-pattern>
    </servlet-mapping>
    <servlet-mapping id="coldfusion_mapping_19">
    <servlet-name>CfmServlet</servlet-name>
    <url-pattern>*.html/*</url-pattern>
    </servlet-mapping>

    And this in the uriworkermap.properties

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

    Is the problem possibly mapping 16 and 18?
  5. Michael Sprague Says:
    @Jeff - I'm not sure I understand the problem you are presenting. I understand that the error is showing in the error logs, but are HTML and HTM files displaying correctly? You said you see the error several times a day, but it is not clear if you are just seeing this in the logs, or if the pages really aren't working.
  6. Jeff Horne Says:
    I'm sorry Michael. Yes, the pages are displaying. I am just seeing the messages in the logs and am not sure if mappings in web.xml.
  7. Jeff Says:
    Should have ended "I am just seeing the messages in the logs and am not sure if CfmServlet mappings 16 and 18 in web.xml are the cause."
  8. Michael Sprague Says:
    Jeff, I don't think this is related, but I can't say with 100% confidence. I am not getting those errors, and I do have the same mappings as you. Given that the pages are working correctly, I think it is unlikely that those mappings are causing the error. Is there anything in the other CF log files that corresponds to these errors (same date/time)?
  9. Jeff Says:
    Thanks. I am looking now. I am not seeing anything in exception or application logs. Checking the others now.
  10. Jeff Says:
    Nothing in any of the other CF logs that match that same date/time stamp.
  11. Jeff Says:
    What I am wondering is does the uriworkermap.properties also need

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

    Like it does for cfm and cfml.

    Right now I just have

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

    So it is not a one to one match with the web.xml cfmServlet entries.
  12. Michael Sprague Says:
    It would only need those mappings if you are processing URLs like this...

    mysite.com/index.html/my-permalink

    In other words, if you want it to process parts of the URI past the .html.

    Adding those into uriworkermap.properties won't hurt anything. Or, if you don't want URLs processed like that, then remove the *.html/* mappings from web.xml.

    I don't know for sure that the error is related, but it won't hurt anything to add (or remove) those entries and try it.
  13. Jeff Says:
    Thanks Mike. Trying to eliminate obvious or semi-obvious possibilities from the puzzle as the error message is not specific about the cause at all. At least not to me. I appreciate your help.
  14. Frank Says:
    Thanks for this helpful article. Helped immensely with my conversion to CF 11. Only lingering problem I have is this:

    My default doc is index.htm which has CF code in it and CF is executing, but when I go to the site root http://mysite.com/ without specifying the file, the contents of index.htm displays but is not executed by CF. Do I need an additional entry in my uriworkermap.properties file?
  15. Mike Says:
    @Frank - Sorry, but I'm not sure what would cause that. Maybe confirm that index.htm is in the welcome-file-list at the bottom of web.xml? This is an old article and I am on CF11 now, so I can't really test it.
  16. Tony Says:
    I am looking to not only process html files with Coldfusion 11, but any files without an extension, aka directories or slugs. For Example: www.domain.com/pages/page.

    Has anyone configured this on CF 11 yet?
  17. Mike Says:
    @Tony - I don't think it is possible to have directories process through ColdFusion. I think you might want to look into using a rewrite rule for that. So, /pages/page would actually rewrite to /something.cfm. It wouldn't be visible to the end user.

    If you use IIS as your web server, I could show you an example of that.

    Otherwise, you might be able to set index.cfm as a default page, and then /pages/page should pull up /pages/page/index.cfm. However, I think that is visible to the end user.

Leave a Reply

Leave this field empty:



Powered by Mango Blog. Design and Icons by N.Design Studio