WikiLens Envelope/Quill JavaServerPages

- Last edited January 3, 2002
Would you like to be able to do a fully validate your jsps as part of an AntBuild?? I have been working on a target that does just this using tomcat's jasper + javac. Here are the relevant bits of the build.xml:

 <property name="tomcat.home" value="C:\APP_SERVERS\TOMCAT"/>

<path id="jasper.classpath" > <pathelement path="${tomcat.home}/lib/servlet.jar"/> <pathelement path="${tomcat.home}/lib/jasper.jar"/> <pathelement path="${tomcat.home}/lib/jasper.jar"/> <pathelement path="${tomcat.home}/lib/webserver.jar"/> <pathelement path="${tomcat.home}/lib/parser.jar"/> <pathelement path="${tomcat.home}/lib/jaxp.jar"/> </path>
<target name="compile_jsp" depends="prepare"> <mkdir dir="temp" /> <java taskname="jasper" classname="org.apache.jasper.JspC" fork="true" failonerror="true" classpathref="jasper.classpath">
<arg value="-v4" /> <arg value="-dd" /><arg value="temp" /> <arg value="-die" /> <arg value="-webapp" /><arg value="${war.dir}" /> </java> <javac srcdir="temp" destdir="temp" debug="false" deprecation="false" optimize = "false" includes="**/*.java"> <classpath refid="jasper.classpath" /> </javac> </target>
Problems (inadequacies):

The jasper section of the above target just generates java code (recursively) from all jsps in the ${war.dir} structure. Top level jsp syntax mistakes are caught.

The javac task then compiles the generated javas to catch script code errors. The problem is you get line numbers from the generated code NOT the jsp. Orion's jsp compiler gives code compile errors with line numbers from the jsp. That would be better.

--MilesD


- Last edited January 3, 2002

https://casino-brain.com/