Monday, 20 June 2005
In a production application you may want to have the jsp's in the app pre-compiled rather than taking the performance hit the first time the page loads. Weblogic server gives you a way to compile your jsp's at build time and package the compiled classes in your ear file. This is a sample ant build script that shows how to use an Ant target to compile jsp pages and build the war file containing the compiled jsps
<?xml version="1.0" encoding="UTF-8"?> <project name="precompile" default="deploy" basedir=".">
<property name="basedir" value="."/> <property name="lib" value="${basedir}/lib"/> <property name="jsp" value="${basedir}/jsp"/> <property name="war.file" value="${basedir}/precompile.war"/> <property name="build.dir" value="${basedir}/build"/> <property name="build.classes" value="${build.dir}/classes"/> <property name="war.dir" value="${build.dir}/war"/>
<path id="cp"> <pathelement path="${build.classes}"/> <fileset dir="${lib}" includes="**/*.jar"/> </path>
<target name="prepare"> <mkdir dir="${build.classes}"/> <mkdir dir="${war.dir}"/> </target> <target name="jsp_precompile" depends="prepare"> <java classname="weblogic.jspc" fork="yes" failonerror="true" output="${basedir}/results.jspc" dir="${jsp}"> <jvmarg value="-Dweblogic.jsp.windows.caseSensitive=true"/>
<arg line="-verbose -noTryBlocks -depend -compileAll -webapp ${war.dir} -d ${war.dir}/WEB-INF ."/> <classpath refid="cp"/> </java> </target>
<target name="deploy" depends="jsp_precompile"> <copy todir="${war.dir}"> <fileset dir="${basedir}/jsp"/> <fileset dir="${basedir}/html"/> </copy> <copy todir="${war.dir}/WEB-INF"> <fileset dir="${basedir}/etc"/> </copy> <jar jarfile="${war.file}" basedir="${war.dir}"/>
</target>
<target name="clean"> <delete dir="${build.classes}"/> <delete dir="${war.dir}"/> <delete file="${war.file}"/> </target> </project> Only registered users can write comments. Please login or register. Powered by AkoComment 1.0 beta 2! |