XpdWiki

FrontPage
RecentChanges
XtC
FindPage
PageIndex
XpApprentices

Set your name in
UserPreferences

Edit this page

Referenced by
...nobody




JSPWiki v2.0.52


JavaServerPages


The following comment (circa December 2001) is 'much out of date'. The jspc optional ant task seems to do most things I was after.


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

NeilThorne plays devil's advocate- are JSP's a good thing? What are the JspAlternatives? Sorry this is here but there aren't many other JSP links on the XPWIKI...


Edit this page   More info...   Attach file...
This page last changed on 17-Aug-2004 14:47:27 BST by MilesD.