First number 2 - i do not have that problem. And i have pretty complex struts app. Does the precompile posted work? Second number 1 - here is my web.xml
Posted by: Cal
Two questions: 1) Can you provide an example of your ${ant.template.dir}/web.xml ? (I am using freemarker.org for the same). Is it just a @generated@ ? 2) Did you also use struts and run into "_jspx_meth_* (javax.servlet.jsp.tagext.JspTag,javax.servlet.jsp.PageContext) cannot be applied to (org.apache.struts.taglib.*.*Tag,javax.servlet.jsp.PageContext)" as per http://nagoya.apache.org/bugzilla/show_bug.cgi?id=29160
Posted by: Ralf Hauser
Adding precompiled jsps with Tomcat 5 is actually pretty easy to bring into the build process. First the environment - I was trying to precompile jsps built on Struts 1.1 and Tiles. My previous attempts in Tomcat 3 were foiled by the complexity of the process. In Tomcat 5 the documentation provides a good example of setting up the Jasper 2 compiler to precompile your application.
The key is to create the exploded WAR and then invoke the jspc and javac on that structure. Since they both need all the classes, libraries, and jsps. My development project structure is below. The Tomcat example does the precompile on the exploded war in the webapps directory - I use a build directory to pull all the items together prior to making a war file.
First you create the servlets - in following the example I placed them in the WEB-INF directory. Then you compile the servlets and for me they were compiled into the build/classes directory. Next you need to map all the new servlets to the .jsp requests so I replace a token with the generated_web.xml in my web.xml. This last step makes the build process automated but means your web.xml is built by ant. I have not included the compile and war targets.
project
-->src <-- all .java files
-->build
---->classes <-- all classes including precompiled jsps
---->WEB-INF
---->META-INF
-->WebRoot
---->web <-- html/jsp/css/etc
---->META-INF
---->WEB-INF
------>classes <-- compiled classes from the project/src the real java classes
------>src <-- used to store the jsp servlets created in jspc target
------>lib
<target name="jspc">
<delete dir="${WEB-INF.dir}/src"/>
<taskdef name="jasper2" classname="org.apache.jasper.JspC" >
<classpath id="jspc.classpath">
<pathelement location="${java.home}/../lib/tools.jar"/>
<fileset dir="${my.catalina.home}/server/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${my.catalina.home}/common/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<jasper2
validateXml="false"
uriroot="${WebRoot.dir}"
webXmlFragment="${WEB-INF.dir}/generated_web.xml"
outputDir="${WEB-INF.dir}/src" />
</target>
<target name="compilejsp">
<javac destdir="${build.classes.dir}"
optimize="off"
debug="on"
failonerror="false"
srcdir="${WEB-INF.dir}/src"
excludes="**/*.smap">
<classpath>
<pathelement location="${WEB-INF.dir}/classes"/>
<fileset dir="${WEB-INF.dir}/lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${my.catalina.home}/common/classes"/>
<fileset dir="${my.catalina.home}/common/lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${my.catalina.home}/shared/classes"/>
<fileset dir="${my.catalina.home}/shared/lib">
<include name="*.jar"/>
</fileset>
</classpath>
<include name="**" />
<exclude name="tags/**" />
</javac>
</target>
<target name="compile-jsps" depends="init, compile, jspc,compilejsp">
<loadfile property="file" srcFile="${WEB-INF.dir}/generated_web.xml"/>
<copy file="${ant.template.dir}/web.xml"
toFile="${WEB-INF.dir}/web.xml" filtering="on" overwrite="yes">
<filterset>
<filter token="generated" value="${file}"/>
</filterset>
</copy>
</target>
