Server Side Includes (SSI) with Netbeans 6 and Tomcat 6.0.14

Searching for info about this gave me a lot of hits that either contained oudated or incomplete information. I eventually got it to work but it was a complete pain in the arse!

First thing to realise is that if you are doing local development with Netbeans and the BUNDLED version of Tomcat the configuration files you need to edit are NOT in the Tomcat directory!
You will find them in ~/.netbeans/6.0/apache-tomcat-6.0.14/conf

DO NOT EDIT the ones in ~/apache-tomcat-6.0.14/conf or else you will just waste a lot of time.

What to change

1. Three sections of ~/.netbeans/6.0/apache-tomcat-6.0.14/conf/web.xml need to be uncommented.
The first is:

The second is:

2. In the first section you might also need to change a few of the default values. To get things to work I had to set buffered false (0) and expires to 1. Additionally, I set debug to 1 (true) and isVirtualWebappRelative to 1 (true). So this section ended up looking like:

I found that without making the additional changes I could get normal SSI directives to work e.g. this worked:
<!--#echo var="DATE_GMT"-->
BUT, I would get errors if I tried to include the output of a servlet.

3. The third section is:

Files that are processed by the SSIServlet have a shtml extension. In order to get this to work with Firefox I had to change the mime-type to:

Before doing this Firefox would prompt me to pick an application to handle the file.

4. When you create your web application you will need to set it as privileged. You do this in the context.xml file. Assuming you have created your app/project using the Netbeans IDE you will find this file in web/META-INF/context.xml.
I changed it to:

5. I used the IDE to restart Tomcat, rebuilt my app then selected run. It worked.

If you check the tomcat log window you will find a number of security exceptions are thrown when tomcat restarts. I *think* this is because none of the default / example projects (inculding the manager) are set as privileged.
This doesn't seem to cause any problems... but I'm not developing a production system - I'm just doing this as part of a course.