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
|
---|
33 | compiler, you should seriously consider using the task shipping with
|
---|
34 | Tomcat instead. This task is only tested against Tomcat 4.x. There
|
---|
35 | are known problems with Tomcat 5.x that won't get fixed in Ant, please
|
---|
36 | use Tomcat's jspc task instead.</p>
|
---|
37 |
|
---|
38 | <p>
|
---|
39 |
|
---|
40 | It can be used to precompile JSP pages for fast initial invocation
|
---|
41 | of JSP pages, deployment on a server without the full JDK installed,
|
---|
42 | or simply to syntax check the pages without deploying them.
|
---|
43 | In most cases, a javac task is usually the next stage in the build process.
|
---|
44 | The task does basic dependency checking to prevent unnecessary recompilation -this
|
---|
45 | checking compares source and destination timestamps, and does not factor
|
---|
46 | in class or taglib dependencies, or <code><jsp:include></code> references.
|
---|
47 |
|
---|
48 | <p>
|
---|
49 | By default the task uses the Jasper JSP compiler. This
|
---|
50 | means the task needs jasper.jar and jasper-runtime.jar, which come with
|
---|
51 | builds of Tomcat 4/Catalina from the
|
---|
52 | <a href="http://jakarta.apache.org/tomcat/">Jakarta Tomcat project</a>,
|
---|
53 | and any other Jar files which may be needed in future versions (it changes)
|
---|
54 |
|
---|
55 | We recommend (in March 2003) Tomcat version 4.1.x for the most robust version
|
---|
56 | of Jasper.
|
---|
57 |
|
---|
58 | <p>
|
---|
59 | There are many limitations with this task which partially stem from the
|
---|
60 | many 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
|
---|
62 | around jasper). Because of this and the fact that JSP pages do not have
|
---|
63 | to be portable across implementations -or versions of implementations-
|
---|
64 | this task is better used for validating JSP pages before deployment,
|
---|
65 | rather than precompiling them. For that, just deploy and run your httpunit
|
---|
66 | junit tests after deployment to compile and test your pages, all in one
|
---|
67 | go.
|
---|
68 |
|
---|
69 | </p>
|
---|
70 |
|
---|
71 |
|
---|
72 | <h3>Parameters</h3>
|
---|
73 | The 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
|
---|
185 | one line per call format. There are comments above and below the mapped
|
---|
186 | write calls to localize where in the JSP file each line of text comes
|
---|
187 | from. This can lead to a minor performance degradation (but it is bound
|
---|
188 | by a linear complexity). Without this options all adjacent writes are
|
---|
189 | concatenated into a single write.</P>
|
---|
190 |
|
---|
191 | <P>The <tt>ieplugin</tt> option is used by the <tt><jsp:plugin></tt> tags.
|
---|
192 | If the Java Plug-in COM Class-ID you want to use changes then it can be
|
---|
193 | specified here. This should not need to be altered.</P>
|
---|
194 |
|
---|
195 | <P><tt>uriroot</tt> specifies the root of the web
|
---|
196 | application. This is where all absolute uris will be resolved from.
|
---|
197 | If it is not specified then the first JSP page will be used to derive
|
---|
198 | it. To derive it each parent directory of the first JSP page is
|
---|
199 | searched for a <tt>WEB-INF</tt> directory, and the directory closest to
|
---|
200 | the JSP page that has one will be used. If none can be found then the
|
---|
201 | directory Jasperc was called from will be used. This only affects pages
|
---|
202 | translated from an explicitly declared JSP file -including references
|
---|
203 | to taglibs</P>
|
---|
204 |
|
---|
205 | <P><tt>uribase</tt> is used to establish the uri context of
|
---|
206 | relative URI references in the JSP pages. If it does not exist then it
|
---|
207 | is derived from the location of the file relative to the declared or
|
---|
208 | derived value of <tt>uriroot</tt>. This only affects pages
|
---|
209 | translated from an explicitly declared JSP file.</P>
|
---|
210 |
|
---|
211 | <h3>Parameters specified as nested elements</h3>
|
---|
212 |
|
---|
213 | This 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
|
---|
215 | files 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 |
|
---|
220 | Elements specific to the jspc task are:-
|
---|
221 |
|
---|
222 | <h4>classpath</h4>
|
---|
223 |
|
---|
224 | The classpath used to compile the JSP pages, specified as for any other
|
---|
225 | classpath.
|
---|
226 |
|
---|
227 | <h4>classpathref</h4>
|
---|
228 | a reference to an existing classpath
|
---|
229 |
|
---|
230 | <h4>webapp</h4>
|
---|
231 | Instructions to jasper to build an entire web application.
|
---|
232 | The base directory must have a WEB-INF subdirectory beneath it.
|
---|
233 | When 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 | <jspc srcdir="${basedir}/src/war"
|
---|
249 | destdir="${basedir}/gensrc"
|
---|
250 | package="com.i3sp.jsp"
|
---|
251 | compiler="jasper41"
|
---|
252 | verbose="9">
|
---|
253 | <include name="**/*.jsp"/>
|
---|
254 | </jspc>
|
---|
255 | </pre>
|
---|
256 | Build all jsp pages under src/war into the destination /gensrc, in a
|
---|
257 | package hierarchy beginning with com.i3sp.jsp.
|
---|
258 | <pre>
|
---|
259 | <jspc
|
---|
260 | destdir="interim"
|
---|
261 | verbose="1"
|
---|
262 | srcdir="src"
|
---|
263 | compiler="jasper41"
|
---|
264 | package="com.i3sp.jsp">
|
---|
265 | <include name="**/*.jsp"/>
|
---|
266 | </jspc>
|
---|
267 | <depend
|
---|
268 | srcdir="interim"
|
---|
269 | destdir="build"
|
---|
270 | cache="build/dependencies"
|
---|
271 | classpath="lib/taglibs.jar"/>
|
---|
272 | <javac
|
---|
273 | srcdir="interim"
|
---|
274 | destdir="build"
|
---|
275 | classpath="lib/taglibs.jar"
|
---|
276 | debug="on"/>
|
---|
277 | </pre>
|
---|
278 | Generate jsp pages then javac them down to
|
---|
279 | bytecodes. Include lib/taglib jar in the java compilation.
|
---|
280 | Dependency checking is used to scrub the
|
---|
281 | java files if class dependencies indicate it is needed.
|
---|
282 |
|
---|
283 | <p><h4>Notes</h4>
|
---|
284 | Using the <code>package</code> attribute it is possible to identify the resulting
|
---|
285 | java files and thus do full dependency checking - this task should only rebuild
|
---|
286 | java files if their jsp file has been modified. However, this only works
|
---|
287 | with some versions of jasper. By default the checking supports tomcat 4.0.x
|
---|
288 | with the "jasper" compiler, set the compiler to "jasper41" for the tomcat4.1.x
|
---|
289 | dependency checking.
|
---|
290 | Even when it does work, changes in
|
---|
291 | .TLD imports or in compile time includes do not get picked up.
|
---|
292 |
|
---|
293 | <p>
|
---|
294 | Jasper generates JSP pages against the JSP1.2 specification -a copy of
|
---|
295 | version 2.3 of the servlet specification is needed on the classpath to
|
---|
296 | compile the Java code.
|
---|
297 |
|
---|
298 |
|
---|
299 |
|
---|
300 | </body>
|
---|
301 | </html>
|
---|
302 |
|
---|