Tomcat Tip - host specific web.xml

One of the issues I had with Tomcat is that while I'm running Mango blog on my VPS, not everyone else on my VPS is. So, how do I create 'host' specific servlet-mappings without impacting everyone else on my box? As I was digging into the issue, the answer is at the top of Tomcat's web.xml file (located in { tomcat installation dir/conf/web.xml }:

  <!-- ======================== Introduction ============================== -->
<!-- This document defines default values for *all* web applications -->
<!-- loaded into this instance of Tomcat. As each application is -->
<!-- deployed, this file is processed, followed by the -->
<!-- "/WEB-INF/web.xml" deployment descriptor from your own -->
<!-- applications. -->
<!-- -->
<!-- WARNING: Do not configure application-specific resources here! -->
<!-- They should go in the "/WEB-INF/web.xml" file in your application. -->

I hadn't paid attention to this before. Definitely a 'duh' moment. So, inside my web-rat.com's WEB-INF directory, I created a web.xml file with the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
    version="2.5">
        <servlet-mapping>
       <servlet-name>RailoCFMLServlet</servlet-name>
       <url-pattern>/blog/post.cfm/*</url-pattern>
       <url-pattern>/blog/page.cfm/*</url-pattern>
       <url-pattern>/blog/archives.cfm/*</url-pattern>
       <url-pattern>/blog/feeds/rss.cfm/*</url-pattern>
    </servlet-mapping>
</web-app>

Thanks to Tom King (@Neokoenig) for mentioning the Mango specific filters on the Railo list and prompting me to investigate because I knew that my blog archive wasn't working properly. Now they are. :)

Update: Fixed / condensed XML - had some stuff that wasn't necessary. Also, please note "RailoCFMLServlet" should be whatever the <servlet-name> is that you defined in your Tomcat's web.xml.

Leave a comment


(required field)

(required field)