An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Quick Tip: Railo on Tomcat

May 7, 2009 ·

Railo includes it's own FileServlet for serving up non-CFML files. If you are running Railo on Tomcat, it is easy to tell Railo to use Tomcat's Servlet instead of its own. Edit the Railo web.xml file in WEB-INF/ and find this XML:
Change it to this:
Restart Tomcat. Now all your non-CFML files are served directly via Tomcat. While developing and testing, it's often useful to have directory listings enabled so you can browse directories (particularly if you have directories full of example / test code). There's no way to enable that with Railo's FileServlet but you can do it for the default Tomcat Servlet by changing the listings setting in the global web.xml file (in Tomcat's conf/ directory):

Tags: coldfusion · railo

9 responses

  • 1 Aaron Greenlee // May 8, 2009 at 3:44 AM

    Thanks, Sean.
  • 2 John Allen // May 8, 2009 at 7:23 AM

    Its these little nuggets that make me sing.

    Thanks especially for the dir listing tip.

    I'm really loving Railo. It is mind blowing fast.
  • 3 Michael Offner // May 13, 2009 at 7:10 AM

    one good thing about this is that this FileServlet also take care on mappings defined in railo administrator.
    you can call files in browser via mapping name:

    one bad thing (and the reasion that this servlet is not enabled by default) this servlet is not realy powerfull, it has no caching mechanisms,like most fileservlet impl have.
  • 4 The Internet // Jun 4, 2009 at 4:56 PM

    Hey Sean, would the servlet-mapping you've implemented here be justification to drop Apache as my web-server and go with Tomcat exclusively? Right now I am running Apache for serving static content and for URL rewriting. Can Tomcat (on Jboss) handle all of the rewriting? Would this be a reasonable move to drop Apache?
  • 5 Sean Corfield // Jun 4, 2009 at 10:29 PM

    Tomcat is certainly a very capable, production quality web server. I personally like the way Apache works so I'd probably keep it in front of Tomcat and let it handle static assets and .htaccess and rewrites etc. I think it's really personal preference tho'...
  • 6 The Internet // Jun 5, 2009 at 4:22 AM

    Well, I prefer Apache, I just thought maybe there was a benefit to doing it with this tip. :) Thanks!
  • 7 Ken Clarke // Jan 11, 2011 at 11:18 AM

    So what are the pros and cons of using Tomcat's servlet vs Railo's for non-CFML pages (other than directory listing of course :) ?
  • 8 Sean Corfield // Jan 16, 2011 at 9:47 PM

    @Ken, no idea. I guess if you want a portable, no fuss FileServlet that behaves the same on all Servlet engines, you might choose Railo's. It's present for that reason.
  • 9 Sean Corfield // Jan 16, 2011 at 9:48 PM

    @Ken, just noticed Micha's earlier comment: Railo's FileServlet respects mappings in the Railo Administrator so that would also be a reason to use it.