NOTE: The configuration for version 2.0 of the jspc-maven-plugin has changed and you will need to update your pom.xml configuration to use the plugin correctly.

WAR Projects

You must use this plugin in conjunction with the maven-war-plugin . The maven-war-plugin must have its webXml configuration parameter set to the newly created web.xml , which is ${pom.basedir}/target/jspweb.xml by default.

    <!-- Use the Tomcat 6 JSP compiler -->


If you are using Servlet 2.4 or later, there is no need to place a web fragment tag in your web.xml file. The plugin will simply append it at the end.

However, if you want a specific location in your web.xml file that you want to inject your web fragment, you can do so by placing a tag that tells the JSPC plugin where to inject the servlet/jsp mapping.

First, in the pom, you need to set the configuration parameter to the fragment tag to look for, such as:


However, keep in mind that since the pom is based on XML, you need to escape your XML. Your setup would look like the following:

    <injectString>&lt;!-- [INSERT FRAGMENT HERE] --&gt;</injectString>

Then in your web.xml file, you need to place the tag where you want the injection to occur. A good place is generally right after your last declared servlet and before the servlet-mapping. Here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="2.4">
        <!-- servlets defined here -->
        <!-- mappings defined here -->

Non-WAR Projects

You can also use this plugin with non-war projects, for instance to validate JSPs. They will be compiled, but not included in your final artifact, and no web.xml file will be generated or modified.

If you want to just validate and compile your JSPs without actually including the generated code in your war project, you can also use set the includeInProject parameter to false.