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