source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/docs/manual/OptionalTasks/jspc.html@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 10.0 KB
Line 
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
17compiler, you should seriously consider using the task shipping with
18Tomcat instead. This task is only tested against Tomcat 4.x. There
19are known problems with Tomcat 5.x that won't get fixed in Ant, please
20use Tomcat's jspc task instead.</p>
21
22<p>
23
24It can be used to precompile JSP pages for fast initial invocation
25of JSP pages, deployment on a server without the full JDK installed,
26or simply to syntax check the pages without deploying them.
27In most cases, a javac task is usually the next stage in the build process.
28The task does basic dependency checking to prevent unnecessary recompilation -this
29checking compares source and destination timestamps, and does not factor
30in class or taglib dependencies, or <code>&lt;jsp:include&gt;</code> references.
31
32<p>
33By default the task uses the Jasper JSP compiler. This
34means the task needs jasper.jar and jasper-runtime.jar, which come with
35builds of Tomcat 4/Catalina from the
36<a href="http://jakarta.apache.org/tomcat/">Jakarta Tomcat project</a>,
37and any other Jar files which may be needed in future versions (it changes)
38
39We recommend (in March 2003) Tomcat version 4.1.x for the most robust version
40of Jasper.
41
42<p>
43There are many limitations with this task which partially stem from the
44many 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
46around jasper). Because of this and the fact that JSP pages do not have
47to be portable across implementations -or versions of implementations-
48this task is better used for validating JSP pages before deployment,
49rather than precompiling them. For that, just deploy and run your httpunit
50junit tests after deployment to compile and test your pages, all in one
51go.
52
53</p>
54
55
56<h3>Parameters</h3>
57The 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
169one line per call format. There are comments above and below the mapped
170write calls to localize where in the JSP file each line of text comes
171from. This can lead to a minor performance degradation (but it is bound
172by a linear complexity). Without this options all adjacent writes are
173concatenated into a single write.</P>
174
175<P>The <tt>ieplugin</tt> option is used by the <tt>&lt;jsp:plugin&gt;</tt> tags.
176If the Java Plug-in COM Class-ID you want to use changes then it can be
177specified here. This should not need to be altered.</P>
178
179<P><tt>uriroot</tt> specifies the root of the web
180application. This is where all absolute uris will be resolved from.
181If it is not specified then the first JSP page will be used to derive
182it. To derive it each parent directory of the first JSP page is
183searched for a <tt>WEB-INF</tt> directory, and the directory closest to
184the JSP page that has one will be used. If none can be found then the
185directory Jasperc was called from will be used. This only affects pages
186translated from an explicitly declared JSP file -including references
187to taglibs</P>
188
189<P><tt>uribase</tt> is used to establish the uri context of
190relative URI references in the JSP pages. If it does not exist then it
191is derived from the location of the file relative to the declared or
192derived value of <tt>uriroot</tt>. This only affects pages
193translated from an explicitly declared JSP file.</P>
194
195<h3>Parameters specified as nested elements</h3>
196
197This 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
199files 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
204Elements specific to the jspc task are:-
205
206<h4>classpath</h4>
207
208The classpath used to compile the JSP pages, specified as for any other
209classpath.
210
211<h4>classpathref</h4>
212a reference to an existing classpath
213
214<h4>webapp</h4>
215Instructions to jasper to build an entire web application.
216The base directory must have a WEB-INF subdirectory beneath it.
217When 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&lt;jspc srcdir="${basedir}/src/war"
233 destdir="${basedir}/gensrc"
234 package="com.i3sp.jsp"
235 compiler="jasper41"
236 verbose="9"&gt;
237 &lt;include name="**/*.jsp"/&gt;
238&lt;/jspc&gt;
239</pre>
240Build all jsp pages under src/war into the destination /gensrc, in a
241package hierarchy beginning with com.i3sp.jsp.
242<pre>
243
244&lt;jspc
245 destdir="interim"
246 verbose="1"
247 srcdir="src"
248 compiler="jasper41"
249 package="com.i3sp.jsp"&gt;
250 &lt;include name="**/*.jsp"/&gt;
251&lt;/jspc&gt;
252&lt;depend
253 srcdir="interim"
254 destdir="build"
255 cache="build/dependencies"
256 classpath="lib/taglibs.jar"/&gt;
257&lt;javac
258 srcdir="interim"
259 destdir="build"
260 classpath="lib/taglibs.jar"
261 debug="on"/&gt;
262</pre>
263Generate jsp pages then javac them down to
264bytecodes. Include lib/taglib jar in the java compilation.
265 Dependency checking is used to scrub the
266java files if class dependencies indicate it is needed.
267
268<p><h4>Notes</h4>
269Using the <code>package</code> attribute it is possible to identify the resulting
270java files and thus do full dependency checking - this task should only rebuild
271java files if their jsp file has been modified. However, this only works
272with some versions of jasper. By default the checking supports tomcat 4.0.x
273with the "jasper" compiler, set the compiler to "jasper41" for the tomcat4.1.x
274dependency checking.
275Even when it does work, changes in
276.TLD imports or in compile time includes do not get picked up.
277
278<p>
279Jasper generates JSP pages against the JSP1.2 specification -a copy of
280version 2.3 of the servlet specification is needed on the classpath to
281compile the Java code.
282
283<hr>
284<p align="center">Copyright &copy; 2001-2004 The Apache Software Foundation. All rights
285Reserved.</p>
286
287</body>
288</html>
289
Note: See TracBrowser for help on using the repository browser.