jspc

Description

Ant task to run the jsp compiler.

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.

The task needs jasper.jar and jasper-runtime.jar, which come with builds of Tomcat 4/Catalina from the Jakarta Tomcat project

Parameters

The Task has the following attributes:

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
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, and bring in any tag libraries. 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

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.

Parameters specified as nested elements

This task is a directory based task, like javac, so the jsp files to be compiled are located as java files are by javac. That is, elements such as includes and excludes can be used directly inside the task declaration.

Elements specific to the jspc task are:-

classpath

The classpath used to compile the JSP pages is specified as for any other classpath. Even if the jasper jars are in the ant library directory, or are on the classpath in some other means, this element is important when referring to tag libraries.

classpathref

a reference to an existing classpath

Example

<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">
      classpath="lib/taglibs.jar"
      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 JSP build and the compilation. Dependency checking is used to scrub the java files if class dependencies indicate it is needed.

Notes

At present, this task only supports the jasper compiler. In future, other compilers will be supported by setting the jsp.compiler property.

The jasper compiler option -webapp is not supported. Using the 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.


Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.