Every tech-oriented person I know has a standard set of tools they install on a machine when they get assigned to it. Recently I’ve found that I include Tomcat in my list. Not only does it serve regular html and jsp out of the box, but with a bit of web.xml trickery you can have it running python and perl applications as well.

To get Python executing inside the tomcat container…

  1. rename $TOMCAT_ROOT/server/lib/servlets-cgi.renametojar to servlets-cgi.jar
  2. add the following items to their appropriate section in $TOMCAT_ROOT/conf/web.xml ``` python org.apache.catalina.servlets.CGIServlet executable python 5
        
    
    python *.py

    ```

  3. Restart tomcat

To get perl running inside the tomcat container…

  1. rename $TOMCAT_ROOT/server/lib/servlets-cgi.renametojar to servlets-cgi.jar
  2. add the following items to their appropriate section in $TOMCAT_ROOT/conf/web.xml ``` perl org.apache.catalina.servlets.CGIServlet executable perl 5
        
    
    perl *.pl

    ```

  3. Restart tomcat

Note: It appears you need to have ‘python’ and ‘perl’ in your path to have this work, but that is likely already the case in most systems you would be doing this to anyways.