You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

jspc.html 8.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>JSPC Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="jspc">jspc</a></h2>
  8. <h3>Description</h3>
  9. <p> Ant task to run the JSP compiler and turn JSP pages into Java source.
  10. <p>
  11. It can be used to precompile JSP pages for fast initial invocation
  12. of JSP pages, deployment on a server without the full JDK installed,
  13. or simply to syntax check the pages without deploying them.
  14. In most cases, a javac task is usually the next stage in the build process.
  15. The task does basic dependency checking to prevent unnecessary recompilation -this
  16. checking compares source and destination timestamps, and does not factor
  17. in class or taglib dependencies, or &lt;jsp:include&gt; references.
  18. <p>
  19. By default the task uses the Jasper JSP compiler. This
  20. means the task needs jasper.jar and jasper-runtime.jar, which come with
  21. builds of Tomcat 4/Catalina from the
  22. <a href="http://jakarta.apache.org/tomcat/">Jakarta Tomcat project</a>
  23. <h3>Parameters</h3>
  24. The Task has the following attributes:<p>
  25. <table border="1" cellpadding="2" cellspacing="0">
  26. <tr>
  27. <td valign="top"><b>Attribute</b></td>
  28. <td valign="top"><b>Description</b></td>
  29. <td align="center" valign="top"><b>Required</b></td>
  30. </tr>
  31. <tr>
  32. <td valign="top">destdir</td>
  33. <td valign="top">Where to place the generated files. They are located
  34. under here according to the given package name.</td>
  35. <td valign="top" align="center">Yes</td>
  36. </tr>
  37. <tr>
  38. <td valign="top">srcdir</td>
  39. <td valign="top">Where to look for source jsp files.</td>
  40. <td valign="top" align="center">Yes</td>
  41. </tr>
  42. <tr>
  43. <td valign="top">verbose</td>
  44. <td valign="top">The verbosity integer to pass to the compiler. Default="0"</td>
  45. <td valign="top" align="center">No</td>
  46. </tr>
  47. <tr>
  48. <td valign="top">package</td>
  49. <td valign="top">Name of the destination package for generated java
  50. classes.</td>
  51. <td valign="top" align="center">No</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">compiler</td>
  55. <td valign="top">class name of a JSP compiler adapter</td>
  56. <td valign="top" align="center">No</td>
  57. </tr>
  58. <tr>
  59. <td valign="top">ieplugin</td>
  60. <td valign="top">Java Plugin classid for Internet Explorer.</td>
  61. <td valign="top" align="center">No</td>
  62. </tr>
  63. <tr>
  64. <td valign="top">mapped</td>
  65. <td valign="top">(boolean) Generate separate write() calls for each HTML
  66. line in the JSP.</td>
  67. <td valign="top" align="center">No</td>
  68. </tr>
  69. <tr>
  70. <td valign="top">classpath</td>
  71. <td valign="top">The classpath to use to run the jsp compiler.
  72. This can also be specified
  73. by the nested element <code>classpath</code>
  74. <a href="../using.html#path">Path</a>).</td>
  75. <td valign="top" align="center">No</td>
  76. </tr>
  77. <tr>
  78. <td valign="top">classpathref</td>
  79. <td valign="top">A <a href="../using.html#references">Reference</a>. As
  80. per <code>classpath</code></td>
  81. <td valign="top" align="center">No</td>
  82. </tr>
  83. <tr>
  84. <td valign="top">failonerror</td>
  85. <td valign="top">flag to control action on compile failures: default=yes</td>
  86. <td valign="top" align="center">No</td>
  87. </tr>
  88. <tr>
  89. <td valign="top">uribase</td>
  90. <td valign="top">
  91. The uri context of relative URI
  92. references in the JSP pages. If it does not
  93. exist then it is derived from the location of the file
  94. relative to the declared or derived value of <tt>uriroot.</tt>
  95. </td>
  96. <td valign="top" align="center">No</td>
  97. </tr>
  98. <tr>
  99. <td valign="top">uriroot</td>
  100. <td valign="top">
  101. The root directory that uri files should be resolved
  102. against.
  103. </td>
  104. <td valign="top" align="center">No</td>
  105. </tr>
  106. <tr>
  107. <td valign="top">compiler</td>
  108. <td valign="top">
  109. Class name of jsp compiler adapter to use. Defaults to
  110. the standard adapter for Jasper.
  111. </td>
  112. <td valign="top" align="center">No</td>
  113. </tr>
  114. <tr>
  115. <td valign="top">compilerclasspath</td>
  116. <td valign="top">The classpath used to find the compiler adapter specified
  117. by the <code>compiler</code> attribute.</td>
  118. <td valign="top" align="center">No</td>
  119. </tr>
  120. </table>
  121. <P>The <tt>mapped</tt> option will, if set to true, split the JSP text content into a
  122. one line per call format. There are comments above and below the mapped
  123. write calls to localize where in the JSP file each line of text comes
  124. from. This can lead to a minor performance degradation (but it is bound
  125. by a linear complexity). Without this options all adjacent writes are
  126. concatenated into a single write.</P>
  127. <P>The <tt>ieplugin</tt> option is used by the <tt>&lt;jsp:plugin&gt;</tt> tags.
  128. If the Java Plug-in COM Class-ID you want to use changes then it can be
  129. specified here. This should not need to be altered.</P>
  130. <P><tt>uriroot</tt> specifies the root of the web
  131. application. This is where all absolute uris will be resolved from.
  132. If it is not specified then the first JSP page will be used to derive
  133. it. To derive it each parent directory of the first JSP page is
  134. searched for a <tt>WEB-INF</tt> directory, and the directory closest to
  135. the JSP page that has one will be used. If none can be found then the
  136. directory Jasperc was called from will be used. This only affects pages
  137. translated from an explicitly declared JSP file -including references
  138. to taglibs</P>
  139. <P><tt>uribase</tt> is used to establish the uri context of
  140. relative URI references in the JSP pages. If it does not exist then it
  141. is derived from the location of the file relative to the declared or
  142. derived value of <tt>uriroot</tt>. This only affects pages
  143. translated from an explicitly declared JSP file.</P>
  144. <h3>Parameters specified as nested elements</h3>
  145. This task is a <a href="../dirtasks.html">directory based task</a>, like
  146. <strong>javac</strong>, so the jsp files to be compiled are located as java
  147. files are by <strong>javac</strong>. That is, elements such as <tt>includes</tt> and
  148. <tt>excludes</tt> can be used directly inside the task declaration.
  149. <p>
  150. Elements specific to the jspc task are:-
  151. <h4>classpath</h4>
  152. The classpath used to compile the JSP pages, specified as for any other
  153. classpath.
  154. <h4>classpathref</h4>
  155. a reference to an existing classpath
  156. <h4>webapp</h4>
  157. Instructions to jasper to build an entire web application.
  158. The base directory must have a WEB-INF subdirectory beneath it.
  159. When used, the task hands off all dependency checking to the compiler.
  160. <table border="1" cellpadding="2" cellspacing="0">
  161. <tr>
  162. <td valign="top"><b>Attribute</b></td>
  163. <td valign="top"><b>Description</b></td>
  164. <td align="center" valign="top"><b>Required</b></td>
  165. </tr>
  166. <tr>
  167. <td valign="top">basedir</td>
  168. <td valign="top">the base directory of the web application</td>
  169. <td valign="top" align="center">Yes</td>
  170. </tr>
  171. </table>
  172. <h3>Example</h3>
  173. <pre>
  174. &lt;jspc srcdir="${basedir}/src/war"
  175. destdir="${basedir}/gensrc"
  176. package="com.i3sp.jsp"
  177. verbose="9"&gt;
  178. &lt;include name="**/*.jsp" /&gt;
  179. &lt;/jspc&gt;
  180. </pre>
  181. Build all jsp pages under src/war into the destination /gensrc, in a
  182. package heirarchy beginning with com.i3sp.jsp.
  183. <pre>
  184. &lt;jspc
  185. destdir="interim"
  186. verbose="1"
  187. srcdir="src"
  188. package="com.i3sp.jsp"&gt;
  189. &lt;include name="**/*.jsp" /&gt;
  190. &lt;/jspc&gt;
  191. &lt;depends
  192. srcdir="interim"
  193. destdir="build"
  194. cache="build/dependencies"
  195. classpath="lib/taglibs.jar"/&gt;
  196. &lt;javac
  197. srcdir="interim"
  198. destdir="build"
  199. classpath="lib/taglibs.jar"
  200. debug="on"/&gt;
  201. </pre>
  202. Generate jsp pages then javac them down to
  203. bytecodes. Include lib/taglib jar in the java compilation.
  204. Dependency checking is used to scrub the
  205. java files if class dependencies indicate it is needed.
  206. <p><h4>Notes</h4>
  207. Using the <code>package</code> attribute it is possible to identify the resulting
  208. java files and thus do full dependency checking - this task only rebuilds
  209. java files if their jsp file has been modified.
  210. <p>
  211. Jasper generates JSP pages against the JSP1.3 specification -an implementation of
  212. version 2.2 of the servlet specification is needed to compile or run the java code.
  213. <hr>
  214. <p align="center">Copyright &copy; 2001-2002 Apache Software Foundation. All rights
  215. Reserved.</p>
  216. </body>
  217. </html>