precompile jsps into classes for Jetty8 using ant

后端 未结 3 1205
情话喂你
情话喂你 2021-01-03 16:03

We are using jspc ant task to pre-compile JSP files into classes/(then package into war)

Now we are switching to Jetty 8. According to the doc, there exists a maven

相关标签:
3条回答
  • 2021-01-03 16:18

    Jasper has jspc; the linked page has ant code for calling it.

    0 讨论(0)
  • 2021-01-03 16:21

    From your first sentence you are apparently already using an ant task to pre-compile the jsp files...so using jetty-8 doesn't mean you have to change that process at all, you will still just pre-compile as you have been, building your war file as you have been and then just deploy into jetty-8. You will need to add jsp to the OPTIONS in the start.ini to get the jsp engine into the server classloader.

    0 讨论(0)
  • 2021-01-03 16:38

    Its best if you use the JSP libs that comes with the jetty distribution.

    Here's an example, using jetty-distribution-8.1.5.v20120716

    <?xml version="1.0" ?>
    <project name="AntExample1" default="war">
    
        <property name="jetty.home" value="${user.home}/code/intalio/distros/jetty-distribution-8.1.5.v20120716" />
    
        <path id="compile.jspc">
            <fileset dir="${jetty.home}">
                <include name="lib/servlet-api-*.jar" />
                <include name="lib/jsp/*.jar" />
            </fileset>
        </path>
    
        <path id="compile.classpath">
            <fileset dir="WebContent/WEB-INF/lib">
                <include name="*.jar" />
            </fileset>
            <path refid="compile.jspc" />
        </path>
    
        <target name="jspc" depends="compile">
            <taskdef classname="org.apache.jasper.JspC" name="jasper2" classpathref="compile.jspc" />
            <jasper2 validateXml="false"
                uriroot="WebContent"
                addWebXmlMappings="true"
                webXmlFragment="WebContent/WEB-INF/generated_web.xml"
                compilerSourceVM="1.6"
                compilerTargetVM="1.6"
                outputDir="build/gen-src"
                verbose="9" />
        </target>
    
        <target name="init">
            <mkdir dir="build/classes" />
            <mkdir dir="build/gen-src" />
            <mkdir dir="dist" />
            <copy todir="build/gen-src">
                <fileset dir="src" includes="**/*.java" />
            </copy>
        </target>
    
        <target name="compile" depends="init">
            <javac destdir="build/classes" debug="true" srcdir="build/gen-src">
                <classpath refid="compile.classpath" />
            </javac>
        </target>
    
        <target name="war" depends="jspc">
            <war destfile="dist/AntExample.war" webxml="WebContent/WEB-INF/web.xml">
                <fileset dir="WebContent" />
            <classes dir="build/classes" />
            </war>
        </target>
    
        <target name="clean">
            <delete dir="dist" />
            <delete dir="build" />
        </target>
    
    </project>
    

    Update: April 8, 2013

    Pushed an example project with this build to github.

    https://github.com/jetty-project/jetty-example-jspc-ant

    0 讨论(0)
提交回复
热议问题