Share

September 21, 2008

Use Maven to precompile your JSP

By adding the following plugins to your pom.xml you will be able to precompile your JSPs and have them included in your war file.

1. part is to include the jspc-mavne-plugin which will complile your jsp into java classess. Make sure to configure the java vesion for the jsp classes.


org.codehaus.mojo
jspc-maven-plugin


jspc

compile


1.5
1.5






2. Update the maven-war-plugin to use the a new web.xml created by the plugin above

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${basedir}/target/jspweb.xml</webXml>
</configuration>
</plugin>

3. you don't have to add anything to you web.xml the new jspweb.xml takes the existing web.xml and addess to it all the needed servlet mapping

<servlet>
<servlet-name>jsp.navs.jsp.footer_jsp</servlet-name>
<servlet-class>jsp.navs.jsp.footer_jsp</servlet-class>
</servlet>