Monday, July 4, 2011

Embedded Tomcat in Maven enable SSI support

As in one of my projects I needed to run a Tomcat server for later deployment of the webapp, I decided to use an embedded variant of the tomcat server in maven.

This works really fine as you can just use a maven plugin:

<!-- To use the plugin goals in your POM or parent POM -->

Important here is to add the extra configuration with mode set to both, i.e. allowing to deploy a given context.xml.

This context.xml is needed to tell tomcat that this webapp needs to be executed in provileged mode. (thus privileged="true" )

Otherwise we would get ane xception like this:
Servlet of class org.apache.catalina.ssi.SSIServlet is privileged and cannot be loaded by this web application

So lets create a context.xml under the META-INF (if not existant create it) in the webapp directory:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="false" privileged="true" useHttpOnly="true" />

Lets now configure our web.xml in order to detect .shtml files and process the SSI inside of them.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns=""


<!-- SSI -->





As you can see we used the SSI Servlet instead of the SSI Filter, which also could be used. Just look into the documentation of tomcat server.

Important: We need to set the mime type differently than the official documentation says. Otherwise FireFox (tested in 4/5) won't detect the document and instead trys to download it.

Thats all of it!

No comments:

Post a Comment