Ant task to run the JSP compiler and turn JSP pages into Java source.
It can be used to precompile JSP pages for fast initial invocation of JSP pages, deployment on a server without the full JDK installed, or simply to syntax check the pages without deploying them. In most cases, a javac task is usually the next stage in the build process. The task does basic dependency checking to prevent unnecessary recompilation -this checking compares source and destination timestamps, and does not factor in class or taglib dependencies, or <jsp:include> references.
By default the task uses the Jasper JSP compiler. This means the task needs jasper.jar and jasper-runtime.jar, which come with builds of Tomcat 4/Catalina from the Jakarta Tomcat project
Attribute | Description | Required |
destdir | Where to place the generated files. They are located under here according to the given package name. | Yes |
srcdir | Where to look for source jsp files. | Yes |
verbose | The verbosity integer to pass to the compiler. Default="0" | No |
package | Name of the destination package for generated java classes. | No |
compiler | class name of a JSP compiler adapter | No |
ieplugin | Java Plugin classid for Internet Explorer. | No |
mapped | (boolean) Generate separate write() calls for each HTML line in the JSP. | No |
classpath | The classpath to use to run the jsp compiler.
This can also be specified
by the nested element classpath
Path). |
No |
classpathref | A Reference. As
per classpath |
No |
failonerror | flag to control action on compile failures: default=yes | No |
uribase | The uri context of relative URI references in the JSP pages. If it does not exist then it is derived from the location of the file relative to the declared or derived value of uriroot. | No |
uriroot | The root directory that uri files should be resolved against. | No |
compiler | Class name of jsp compiler adapter to use. Defaults to the standard adapter for Jasper. | No |
compilerclasspath | The classpath used to find the compiler adapter specified
by the compiler attribute. |
No |
The mapped option will, if set to true, split the JSP text content into a one line per call format. There are comments above and below the mapped write calls to localize where in the JSP file each line of text comes from. This can lead to a minor performance degradation (but it is bound by a linear complexity). Without this options all adjacent writes are concatenated into a single write.
The ieplugin option is used by the <jsp:plugin> tags. If the Java Plug-in COM Class-ID you want to use changes then it can be specified here. This should not need to be altered.
uriroot specifies the root of the web application. This is where all absolute uris will be resolved from. If it is not specified then the first JSP page will be used to derive it. To derive it each parent directory of the first JSP page is searched for a WEB-INF directory, and the directory closest to the JSP page that has one will be used. If none can be found then the directory Jasperc was called from will be used. This only affects pages translated from an explicitly declared JSP file -including references to taglibs
uribase is used to establish the uri context of relative URI references in the JSP pages. If it does not exist then it is derived from the location of the file relative to the declared or derived value of uriroot. This only affects pages translated from an explicitly declared JSP file.
Elements specific to the jspc task are:-
compiler
Attribute | Description | Required |
basedir | the base directory of the web application | Yes |
<jspc srcdir="${basedir}/src/war" destdir="${basedir}/gensrc" package="com.i3sp.jsp" verbose="9"> <include name="**/*.jsp" /> </jspc>Build all jsp pages under src/war into the destination /gensrc, in a package heirarchy beginning with com.i3sp.jsp.
<jspc destdir="interim" verbose="1"> srcdir="src" package="com.i3sp.jsp" <include name="**/*.jsp" /> </jspc> <depends srcdir="interim" destdir="build" cache="build/dependencies" classpath="lib/taglibs.jar"/> <javac srcdir="interim" destdir="build" classpath="lib/taglibs.jar" debug="on" />Generate jsp pages then javac them down to bytecodes. Include lib/taglib jar in the java compilation. Dependency checking is used to scrub the java files if class dependencies indicate it is needed.
package
attribute it is possible to identify the resulting
java files and thus do full dependency checking - this task only rebuilds
java files if their jsp file has been modified.
Jasper generates JSP pages against the JSP1.3 specification -an implementation of version 2.2 of the servlet specification is needed to compile or run the java code.
Copyright © 2001-2002 Apache Software Foundation. All rights Reserved.