Chapter 13 Using jagtool and jagant


compilejsp

Description

Compiles JSP files.

Syntax

Command line:

compilejsp 
[-webapp WebAppName] 
[-uriroot directory] 
[-outputdir directory] 
[-verbose true|false] 
[-debug true|false] 
[-keep true|false] 
[-force true|false] 
[file1 file2 ...]

Ant build file:

<jag_compilejsp
[ webapp="WebAppName" ]
[ uriroot="directory" ]
[ outputdir="directory" ]
[ verbose="true|false" ]
[ debug="true|false" ]
[ keep="true|false" ]
[ force="true|false" ]
[ jspfile="file" ] />

Option Description Required
webapp Compiles the JSP files in the specified Web application. Uses the JAGUAR environment variable to locate the Web application directory. Compiles all JSP files in the Web application unless specific files are specified.

You must specify one of the -webapp or -uriroot options, but not both.

You must specify the -webapp option to compile JSPs that use tag libraries.
No
uriroot Compiles the specified JSP files in the given directory, which must be specified as a complete path. If no files are specified, compiles all JSP files in the directory and its subdirectories.

You must specify one of the -webapp or -uriroot options, but not both.
No
outputdir The full path of the output directory for generated Java source and compiled classes. If the -webapp option is specified, the default is this subdirectory of your EAServer installation directory:
work\server\Servlet\WebApp-WAName


Where server is the name of your server, and WAName is the name of your Web application. To run the JSPs in EAServer, class files must be in this directory.

If the -webapp option is not specified, the default is the current directory.
No
verbose Execute in verbose mode. The default is false . No
debug Compile the generated Java files with debugging information. The default is false . No
keep Keep the generated Java source files rather than deleting them. The default is true . No
force Force compilation of JSP files regardless of whether the class file is newer than the JSP source file. The default is true . No
file1 file2 ... When using the command line, the list of files to compile, with paths specified relative to the Web application root directory, if using the webapp option, or the specified directory, if using the uriroot option. If no files are specified, all files in the specified Web application or directory are compiled. No
jspfile When using Ant, the file to compile with path relative to the relative to the Web application root directory, if using the webapp option, or the specified directory, if using the uriroot option. If no file is specified, all files in the specified Web application or directory are compiled. No

Examples

This command-line example compiles the files jsp/file1.jsp and jsp/file2.jsp in the Web application MyWebApp:

jagtool compilejsp -webapp MyWebApp jsp/file1.jsp jsp/file2.jsp

The output goes to the EAServer directory:

work/server/Servlet/WebApp-MyWebApp

This command-line example recursively compiles all JSPs in the Web application MyWebApp:

jagtool compilejsp -webapp MyWebApp

The output goes to the EAServer directory:

$JAGUAR/work/server/Servlet/WebApp-MyWebApp

Where server is the name of the server you are connected to.

This command-line example compiles file1.jsp in the Web application MyWebApp:

jagtool compilejsp -webapp MyWebApp -outputdir c:\temp file1.jsp

The output goes to c:\temp.

This command-line example compiles file1.jsp in the directory c:\webapps\MyWebAppDir:

jagtool compilejsp -uriroot c:\webapps\MyWebAppDir file1.jsp

The output goes to the current directory.

This command-line example recursively compiles all JSPs in the directory c:\webapps\MyWebAppDir:

jagtool compilejsp -uriroot c:\webapps\MyWebAppDir -outputdir c:\temp

The output goes to c:\temp.

This Ant build file example defines a target to compile two JSP files:

<target name="compilejsp_test" >
  <jag_compilejsp Jspfile="file1.jsp" verbose="false" Uriroot="D:\EAS\Sample\jagtool" />
  <jag_compilejsp Jspfile="file2.jsp" verbose="false" Uriroot="D:\EAS\Sample\jagtool" />
</target>

Usage

To use the compilejsp command in Ant, you must add the location of the xalan.jar and crimson.jar files that are included with EAServer to the Ant CLASSPATH. See "Setting up your environment" for more information.

You can also compile JSPs with the EAServer jspc script. The jspc script invokes jagtool to compile JSPs.

See Also

"Creating JavaServer Pages" in the EAServer Programmer's Guide

 


Copyright © 2002 Sybase, Inc. All rights reserved.