source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual/manual/OptionalTasks/jspc.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

File size: 10.7 KB
Line 
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<meta http-equiv="Content-Language" content="en-us">
21<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22<title>JSPC Task</title>
23</head>
24
25<body>
26
27<h2><a name="jspc">jspc</a></h2>
28<h3>Description</h3>
29
30<p> Ant task to run the JSP compiler and turn JSP pages into Java source.
31
32<p><b>Deprecated</b> if you use this task with Tomcat's Jasper JSP
33compiler, you should seriously consider using the task shipping with
34Tomcat instead. This task is only tested against Tomcat 4.x. There
35are known problems with Tomcat 5.x that won't get fixed in Ant, please
36use Tomcat's jspc task instead.</p>
37
38<p>
39
40It can be used to precompile JSP pages for fast initial invocation
41of JSP pages, deployment on a server without the full JDK installed,
42or simply to syntax check the pages without deploying them.
43In most cases, a javac task is usually the next stage in the build process.
44The task does basic dependency checking to prevent unnecessary recompilation -this
45checking compares source and destination timestamps, and does not factor
46in class or taglib dependencies, or <code>&lt;jsp:include&gt;</code> references.
47
48<p>
49By default the task uses the Jasper JSP compiler. This
50means the task needs jasper.jar and jasper-runtime.jar, which come with
51builds of Tomcat 4/Catalina from the
52<a href="http://jakarta.apache.org/tomcat/">Jakarta Tomcat project</a>,
53and any other Jar files which may be needed in future versions (it changes)
54
55We recommend (in March 2003) Tomcat version 4.1.x for the most robust version
56of Jasper.
57
58<p>
59There are many limitations with this task which partially stem from the
60many versions of Jasper, others from implementation 'issues' in the task
61(i.e. nobody's willingness to radically change large bits of it to work
62around jasper). Because of this and the fact that JSP pages do not have
63to be portable across implementations -or versions of implementations-
64this task is better used for validating JSP pages before deployment,
65rather than precompiling them. For that, just deploy and run your httpunit
66junit tests after deployment to compile and test your pages, all in one
67go.
68
69</p>
70
71
72<h3>Parameters</h3>
73The Task has the following attributes:<p>
74
75<table border="1" cellpadding="2" cellspacing="0">
76 <tr>
77 <td valign="top"><b>Attribute</b></td>
78 <td valign="top"><b>Description</b></td>
79 <td align="center" valign="top"><b>Required</b></td>
80 </tr>
81 <tr>
82 <td valign="top">destdir</td>
83 <td valign="top">Where to place the generated files. They are located
84 under here according to the given package name.</td>
85 <td valign="top" align="center">Yes</td>
86 </tr>
87 <tr>
88 <td valign="top">srcdir</td>
89 <td valign="top">Where to look for source jsp files.</td>
90 <td valign="top" align="center">Yes</td>
91 </tr>
92 <tr>
93 <td valign="top">verbose</td>
94 <td valign="top">The verbosity integer to pass to the compiler. Default="0"</td>
95 <td valign="top" align="center">No</td>
96 </tr>
97 <tr>
98 <td valign="top">package</td>
99 <td valign="top">Name of the destination package for generated java
100 classes.</td>
101 <td valign="top" align="center">No</td>
102 </tr>
103 <tr>
104 <td valign="top">compiler</td>
105 <td valign="top">class name of a JSP compiler adapter,
106 such as "jasper" or "jasper41"</td>
107 <td valign="top" align="center">No -defaults to "jasper"</td>
108 </tr>
109 <tr>
110 <td valign="top">ieplugin</td>
111 <td valign="top">Java Plugin classid for Internet Explorer.</td>
112 <td valign="top" align="center">No</td>
113 </tr>
114 <tr>
115 <td valign="top">mapped</td>
116 <td valign="top">(boolean) Generate separate write() calls for each HTML
117 line in the JSP.</td>
118 <td valign="top" align="center">No</td>
119 </tr>
120 <tr>
121 <td valign="top">classpath</td>
122 <td valign="top">The classpath to use to run the jsp compiler.
123 This can also be specified
124 by the nested element <code>classpath</code>
125 <a href="../using.html#path">Path</a>).</td>
126 <td valign="top" align="center">No, but it seems to work better when used</td>
127 </tr>
128 <tr>
129 <td valign="top">classpathref</td>
130 <td valign="top">A <a href="../using.html#references">Reference</a>. As
131 per <code>classpath</code></td>
132 <td valign="top" align="center">No</td>
133 </tr>
134 <tr>
135 <td valign="top">failonerror</td>
136 <td valign="top">flag to control action on compile failures: default=yes</td>
137 <td valign="top" align="center">No</td>
138 </tr>
139 <tr>
140 <td valign="top">uribase</td>
141 <td valign="top">
142 The uri context of relative URI
143 references in the JSP pages. If it does not
144 exist then it is derived from the location of the file
145 relative to the declared or derived value of <tt>uriroot.</tt>
146 </td>
147 <td valign="top" align="center">No</td>
148 </tr>
149 <tr>
150 <td valign="top">uriroot</td>
151 <td valign="top">
152 The root directory that uri files should be resolved
153 against.
154 </td>
155 <td valign="top" align="center">No</td>
156 </tr>
157 <tr>
158 <td valign="top">compiler</td>
159 <td valign="top">
160 Class name of jsp compiler adapter to use. Defaults to
161 the standard adapter for Jasper.
162 </td>
163 <td valign="top" align="center">No</td>
164 </tr>
165 <tr>
166 <td valign="top">compilerclasspath</td>
167 <td valign="top">The classpath used to find the compiler adapter specified
168 by the <code>compiler</code> attribute.</td>
169 <td valign="top" align="center">No</td>
170 </tr>
171 <tr>
172 <td valign="top">webinc</td>
173 <td valign="top">Output file name for the fraction of web.xml that lists servlets.</td>
174 <td valign="top" align="center">No</td>
175 </tr>
176 <tr>
177 <td valign="top">webxml</td>
178 <td valign="top">File name for web.xml to be generated</td>
179 <td valign="top" align="center">No</td>
180 </tr>
181
182 </table>
183
184<P>The <tt>mapped</tt> option will, if set to true, split the JSP text content into a
185one line per call format. There are comments above and below the mapped
186write calls to localize where in the JSP file each line of text comes
187from. This can lead to a minor performance degradation (but it is bound
188by a linear complexity). Without this options all adjacent writes are
189concatenated into a single write.</P>
190
191<P>The <tt>ieplugin</tt> option is used by the <tt>&lt;jsp:plugin&gt;</tt> tags.
192If the Java Plug-in COM Class-ID you want to use changes then it can be
193specified here. This should not need to be altered.</P>
194
195<P><tt>uriroot</tt> specifies the root of the web
196application. This is where all absolute uris will be resolved from.
197If it is not specified then the first JSP page will be used to derive
198it. To derive it each parent directory of the first JSP page is
199searched for a <tt>WEB-INF</tt> directory, and the directory closest to
200the JSP page that has one will be used. If none can be found then the
201directory Jasperc was called from will be used. This only affects pages
202translated from an explicitly declared JSP file -including references
203to taglibs</P>
204
205<P><tt>uribase</tt> is used to establish the uri context of
206relative URI references in the JSP pages. If it does not exist then it
207is derived from the location of the file relative to the declared or
208derived value of <tt>uriroot</tt>. This only affects pages
209translated from an explicitly declared JSP file.</P>
210
211<h3>Parameters specified as nested elements</h3>
212
213This task is a <a href="../dirtasks.html">directory based task</a>, like
214<strong>javac</strong>, so the jsp files to be compiled are located as java
215files are by <strong>javac</strong>. That is, elements such as <tt>includes</tt> and
216<tt>excludes</tt> can be used directly inside the task declaration.
217
218<p>
219
220Elements specific to the jspc task are:-
221
222<h4>classpath</h4>
223
224The classpath used to compile the JSP pages, specified as for any other
225classpath.
226
227<h4>classpathref</h4>
228a reference to an existing classpath
229
230<h4>webapp</h4>
231Instructions to jasper to build an entire web application.
232The base directory must have a WEB-INF subdirectory beneath it.
233When used, the task hands off all dependency checking to the compiler.
234<table border="1" cellpadding="2" cellspacing="0">
235 <tr>
236 <td valign="top"><b>Attribute</b></td>
237 <td valign="top"><b>Description</b></td>
238 <td align="center" valign="top"><b>Required</b></td>
239 </tr>
240 <tr>
241 <td valign="top">basedir</td>
242 <td valign="top">the base directory of the web application</td>
243 <td valign="top" align="center">Yes</td>
244 </tr>
245</table>
246<h3>Example</h3>
247<pre>
248&lt;jspc srcdir="${basedir}/src/war"
249 destdir="${basedir}/gensrc"
250 package="com.i3sp.jsp"
251 compiler="jasper41"
252 verbose="9"&gt;
253 &lt;include name="**/*.jsp"/&gt;
254&lt;/jspc&gt;
255</pre>
256Build all jsp pages under src/war into the destination /gensrc, in a
257package hierarchy beginning with com.i3sp.jsp.
258<pre>
259&lt;jspc
260 destdir="interim"
261 verbose="1"
262 srcdir="src"
263 compiler="jasper41"
264 package="com.i3sp.jsp"&gt;
265 &lt;include name="**/*.jsp"/&gt;
266&lt;/jspc&gt;
267&lt;depend
268 srcdir="interim"
269 destdir="build"
270 cache="build/dependencies"
271 classpath="lib/taglibs.jar"/&gt;
272&lt;javac
273 srcdir="interim"
274 destdir="build"
275 classpath="lib/taglibs.jar"
276 debug="on"/&gt;
277</pre>
278Generate jsp pages then javac them down to
279bytecodes. Include lib/taglib jar in the java compilation.
280 Dependency checking is used to scrub the
281java files if class dependencies indicate it is needed.
282
283<p><h4>Notes</h4>
284Using the <code>package</code> attribute it is possible to identify the resulting
285java files and thus do full dependency checking - this task should only rebuild
286java files if their jsp file has been modified. However, this only works
287with some versions of jasper. By default the checking supports tomcat 4.0.x
288with the "jasper" compiler, set the compiler to "jasper41" for the tomcat4.1.x
289dependency checking.
290Even when it does work, changes in
291.TLD imports or in compile time includes do not get picked up.
292
293<p>
294Jasper generates JSP pages against the JSP1.2 specification -a copy of
295version 2.3 of the servlet specification is needed on the classpath to
296compile the Java code.
297
298
299
300</body>
301</html>
302
Note: See TracBrowser for help on using the repository browser.