2018-12-21 11:20:43 +01:00
|
|
|
<!DOCTYPE html>
|
2006-09-11 04:19:00 +00:00
|
|
|
<!--
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
2019-05-25 13:41:47 +02:00
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
2006-09-11 04:19:00 +00:00
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
2018-12-21 11:20:43 +01:00
|
|
|
<html lang="en">
|
2001-09-13 08:31:21 +00:00
|
|
|
|
|
|
|
<head>
|
2005-04-29 18:58:16 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
2002-02-03 22:11:39 +00:00
|
|
|
<title>JSPC Task</title>
|
2001-09-13 08:31:21 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2018-01-22 09:10:26 +01:00
|
|
|
<h2 id="jspc">jspc</h2>
|
2018-02-28 07:58:59 +01:00
|
|
|
<h3><em><u>Deprecated</u></em></h3>
|
|
|
|
<p><em>If you use this task with Tomcat's Jasper JSP compiler, you should seriously consider using
|
|
|
|
the task shipping with Tomcat instead.</em> This task is only tested against Tomcat 4.x. There are
|
|
|
|
known problems with Tomcat 5.x that won't get fixed in Ant, please use Tomcat's <code>jspc</code>
|
|
|
|
task instead.<br/> Instead of relying on container-specific JSP compilers we suggest deploying the
|
|
|
|
raw files (<samp>*.jsp</samp>) and use the container build-in functions: after deploying run a test
|
2018-03-08 07:43:53 +01:00
|
|
|
suite (e.g. with <a href="https://attic.apache.org/projects/jakarta-cactus.html"
|
|
|
|
target="_top">Cactus</a> or <a href="http://httpunit.sourceforge.net/" target="_top">HttpUnit</a>)
|
|
|
|
against the deployed web application. So you'll get the test result <em>and</em> the compiled
|
|
|
|
JSPs.</p>
|
2001-09-13 08:31:21 +00:00
|
|
|
<h3>Description</h3>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Apache Ant task to run the JSP compiler and turn JSP pages into Java source files.</p>
|
2004-06-28 08:49:46 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>This task 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 <code>javac</code> 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 <code><jsp:include></code> references.</p>
|
2001-09-28 05:50:33 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>By default the task uses the Jasper JSP compiler. This means the task
|
|
|
|
needs <samp>jasper.jar</samp> and <samp>jasper-runtime.jar</samp>, which come with builds of Tomcat
|
2018-03-08 07:43:53 +01:00
|
|
|
4/Catalina from the <a href="https://tomcat.apache.org/" target="_top">Apache Tomcat project</a>,
|
|
|
|
and any other jar files which may be needed in future versions (it changes).</p>
|
2003-03-11 06:56:35 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>We recommend (in March 2003) Tomcat version 4.1.x for the most robust version of Jasper.</p>
|
2002-12-01 03:48:25 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>There are many limitations with this task which partially stem from the many versions of Jasper,
|
|
|
|
others from implementation 'issues' in the task (i.e. nobody's willingness to radically change large
|
|
|
|
bits of it to work around Jasper). Because of this and the fact that JSP pages do not have to be
|
|
|
|
portable across implementations—or versions of implementations—this task is better used
|
|
|
|
for validating JSP pages before deployment, rather than precompiling them. For the latter, just
|
|
|
|
deploy and run your HttpUnit JUnit tests after deployment to compile and test your pages, all in one
|
|
|
|
go.</p>
|
2001-09-28 05:50:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
<h3>Parameters</h3>
|
2018-01-21 22:11:27 +01:00
|
|
|
<p>The Task has the following attributes:</p>
|
2001-09-13 08:31:21 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2001-09-13 08:31:21 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>destdir</td>
|
|
|
|
<td>Where to place the generated files. They are located under here according to the given
|
|
|
|
package name.</td>
|
|
|
|
<td>Yes</td>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>srcdir</td>
|
|
|
|
<td>Where to look for source JSP files.</td>
|
|
|
|
<td>Yes</td>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>verbose</td>
|
|
|
|
<td>The verbosity integer to pass to the compiler.</td>
|
|
|
|
<td>No; default <q>0</q></td>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>package</td>
|
|
|
|
<td>Name of the destination package for generated Java classes.</td>
|
|
|
|
<td>No</td>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
2002-06-22 23:38:38 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>compiler</td>
|
|
|
|
<td>class name of a JSP compiler adapter, such as <q>jasper</q> or <q>jasper41</q></td>
|
|
|
|
<td>No; defaults to <q>jasper</q></td>
|
2002-06-22 23:38:38 +00:00
|
|
|
</tr>
|
2001-09-13 08:31:21 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>ieplugin</td>
|
|
|
|
<td>Java Plugin classid for Internet Explorer.</td>
|
|
|
|
<td>No</td>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>mapped</td>
|
|
|
|
<td>(boolean) Generate separate <code>write()</code> calls for each HTML line in the JSP.</td>
|
|
|
|
<td>No</td>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>classpath</td>
|
|
|
|
<td>The classpath to use to run the JSP compiler.</td>
|
|
|
|
<td>No, but it seems to work better when used; can also be specified by the nested
|
|
|
|
element <a href="../using.html#path"><code>classpath</code></a></td>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>classpathref</td>
|
|
|
|
<td>A <a href="../using.html#references">Reference</a>. As per <var>classpath</var>.</td>
|
|
|
|
<td>No</td>
|
2001-09-13 08:31:21 +00:00
|
|
|
</tr>
|
2001-09-28 05:50:33 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>failonerror</td>
|
|
|
|
<td>flag to control action on compile failures.</td>
|
|
|
|
<td>No; default <q>yes</q></td>
|
2002-06-22 23:38:38 +00:00
|
|
|
</tr>
|
2001-10-19 00:34:05 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>uribase</td>
|
|
|
|
<td>The context of relative URI references in JSP.</td>
|
|
|
|
<td>No; derived from the location of the file relative to the declared or derived value
|
|
|
|
of <var>uriroot</var></td>
|
2001-10-19 00:34:05 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>uriroot</td>
|
|
|
|
<td>The root directory that URIs should be resolved against.</td>
|
|
|
|
<td>No</td>
|
2002-06-22 23:38:38 +00:00
|
|
|
</tr>
|
2002-06-05 21:02:11 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>compiler</td>
|
|
|
|
<td>Class name of JSP compiler adapter to use.</td>
|
|
|
|
<td>No; defaults to the standard adapter for Jasper</td>
|
2002-06-05 21:02:11 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>compilerclasspath</td>
|
|
|
|
<td>The classpath used to find the compiler adapter specified by the <var>compiler</var>
|
|
|
|
attribute.</td>
|
|
|
|
<td>No</td>
|
2002-06-05 21:02:11 +00:00
|
|
|
</tr>
|
2002-12-01 03:48:25 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>webinc</td>
|
|
|
|
<td>Output file name for the fraction of <samp>web.xml</samp> that lists servlets.</td>
|
|
|
|
<td>No</td>
|
2018-01-21 22:11:27 +01:00
|
|
|
</tr>
|
2002-12-01 03:48:25 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>webxml</td>
|
|
|
|
<td>File name for <samp>web.xml</samp> to be generated</td>
|
|
|
|
<td>No</td>
|
2018-01-21 22:11:27 +01:00
|
|
|
</tr>
|
|
|
|
</table>
|
2002-06-22 23:38:38 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>The <var>mapped</var> option will, if set to <q>true</q>, 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 option all adjacent writes are concatenated into
|
|
|
|
a single write.</p>
|
2001-09-28 05:50:33 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>The <var>ieplugin</var> option is used by the <code><jsp:plugin></code> 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.</p>
|
2001-09-28 05:50:33 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><var>uriroot</var> 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 <samp>WEB-INF</samp>
|
|
|
|
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.</p>
|
2001-10-19 00:34:05 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><var>uribase</var> is used to establish the 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 <var>uriroot</var>. This only affects pages translated from an explicitly declared
|
|
|
|
JSP file.</p>
|
2001-10-19 00:34:05 +00:00
|
|
|
|
2001-09-28 05:50:33 +00:00
|
|
|
<h3>Parameters specified as nested elements</h3>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>This task is a <a href="../dirtasks.html">directory based task</a>, like <code>javac</code>, so
|
|
|
|
the <samp>.jsp</samp> files to be compiled are located as <samp>.java</samp> files are
|
|
|
|
by <code>javac</code>. That is, elements such as <code>includes</code> and <code>excludes</code> can
|
|
|
|
be used directly inside the task declaration.</p>
|
2001-09-13 08:31:21 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Elements specific to the <code>jspc</code> task are:</p>
|
2001-09-28 05:50:33 +00:00
|
|
|
|
|
|
|
<h4>classpath</h4>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>The classpath used to compile the JSP pages, specified as for any other classpath.</p>
|
2001-09-28 05:50:33 +00:00
|
|
|
|
|
|
|
<h4>classpathref</h4>
|
2018-01-21 22:11:27 +01:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>a reference to an existing classpath</p>
|
2001-09-28 05:50:33 +00:00
|
|
|
|
2002-06-22 23:38:38 +00:00
|
|
|
<h4>webapp</h4>
|
2018-01-21 22:11:27 +01:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Instructions to Jasper to build an entire web application. The base directory must have
|
|
|
|
a <samp>WEB-INF</samp> subdirectory beneath it. When used, the task hands off all dependency
|
|
|
|
checking to the compiler.</p>
|
|
|
|
<table class="attr">
|
2002-06-22 23:38:38 +00:00
|
|
|
<tr>
|
2018-05-15 10:29:27 +02:00
|
|
|
<th scope="col">Attribute</th>
|
|
|
|
<th scope="col">Description</th>
|
|
|
|
<th scope="col">Required</th>
|
2002-06-22 23:38:38 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>basedir</td>
|
|
|
|
<td>the base directory of the web application</td>
|
|
|
|
<td>Yes</td>
|
2002-06-22 23:38:38 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
2018-05-15 09:51:58 +02:00
|
|
|
|
2001-09-28 05:50:33 +00:00
|
|
|
<h3>Example</h3>
|
2018-05-15 09:51:58 +02:00
|
|
|
<p>Build all <samp>.jsp</samp> files under <samp>src/war</samp> into the
|
|
|
|
destination <samp>/gensrc</samp>, in a package hierarchy beginning
|
|
|
|
with <samp>com.i3sp.jsp</samp>.</p>
|
2001-09-13 08:31:21 +00:00
|
|
|
<pre>
|
|
|
|
<jspc srcdir="${basedir}/src/war"
|
|
|
|
destdir="${basedir}/gensrc"
|
|
|
|
package="com.i3sp.jsp"
|
2003-01-31 07:14:12 +00:00
|
|
|
compiler="jasper41"
|
2001-09-13 08:31:21 +00:00
|
|
|
verbose="9">
|
2004-11-19 09:07:12 +00:00
|
|
|
<include name="**/*.jsp"/>
|
2018-02-28 07:58:59 +01:00
|
|
|
</jspc></pre>
|
2018-05-15 09:51:58 +02:00
|
|
|
|
|
|
|
<p>Generate <samp>.java</samp> files from <samp>.jsp</samp> files, then <code>javac</code> them down
|
|
|
|
to bytecode. Include <samp>lib/taglibs.jar</samp> in the Java compilation. Dependency checking is
|
|
|
|
used to scrub the <samp>.java</samp> files if class dependencies indicate it is needed.</p>
|
2001-09-28 05:50:33 +00:00
|
|
|
<pre>
|
2018-02-28 07:58:59 +01:00
|
|
|
<jspc destdir="interim"
|
2002-09-02 12:29:38 +00:00
|
|
|
verbose="1"
|
2001-09-28 05:50:33 +00:00
|
|
|
srcdir="src"
|
2003-01-31 07:14:12 +00:00
|
|
|
compiler="jasper41"
|
2002-09-02 12:29:38 +00:00
|
|
|
package="com.i3sp.jsp">
|
2004-11-19 09:07:12 +00:00
|
|
|
<include name="**/*.jsp"/>
|
2001-09-28 05:50:33 +00:00
|
|
|
</jspc>
|
2018-02-28 07:58:59 +01:00
|
|
|
<depend srcdir="interim"
|
2001-09-28 05:50:33 +00:00
|
|
|
destdir="build"
|
|
|
|
cache="build/dependencies"
|
|
|
|
classpath="lib/taglibs.jar"/>
|
2018-02-28 07:58:59 +01:00
|
|
|
<javac srcdir="interim"
|
2001-09-28 05:50:33 +00:00
|
|
|
destdir="build"
|
|
|
|
classpath="lib/taglibs.jar"
|
2018-02-28 07:58:59 +01:00
|
|
|
debug="on"/></pre>
|
2001-09-13 08:31:21 +00:00
|
|
|
|
2018-01-21 22:11:27 +01:00
|
|
|
<h4>Notes</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Using the <var>package</var> attribute it is possible to identify the
|
|
|
|
resulting <samp>.java</samp> files and thus do full dependency checking—this task should only
|
|
|
|
rebuild <samp>.java</samp> files if their <samp>.jsp</samp> file has been modified. However, this
|
|
|
|
only works with some versions of Jasper. By default the checking supports Tomcat 4.0.x with
|
|
|
|
the <q>jasper</q> compiler, set the compiler to <q>jasper41</q> for the Tomcat 4.1.x dependency
|
|
|
|
checking. Even when it does work, changes in <samp>.tld</samp> imports or in compile time includes
|
|
|
|
do not get picked up.</p>
|
|
|
|
<p>Jasper generates JSP pages against the JSP 1.2 specification—a copy of version 2.3 of the
|
|
|
|
servlet specification is needed on the classpath to compile the Java code.</p>
|
2001-09-13 08:31:21 +00:00
|
|
|
</body>
|
|
|
|
</html>
|