Sun Microsystems Logo
Products and Services
Support and Training

A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  
Application Server Utilityjspc(1M)


 jspc - precompiles JSP source files into servlets


 jspc [options] jsp_filesor jspc [options] -webapp dir



Use the jspc command to compile your JSP 1.2 compliant source files into servlets. To allow the application server to pick up the precompiled JSPs from a JAR file, you must disable dynamic reloading of JSPs. To do this, set reload-interval property to -1 in the jsp-config element of the sun-web.xml file.

For more information about the sun-web.xml file, see the Sun ONE Application Server Developer's Guide.


one or more JSP files to be compiled.
-webapp dir
a directory containing a web application. All JSPs in the directory and its subdirectories are compiled. You cannot specify a WAR, JAR, or ZIP file; you must first deploy it to an open directory structure using asadmin deploy.
enables quiet mode (same as -v0). Only fatal error messages are displayed.
-d dir
the output directory for the compiled JSPs. Package directories are automatically generated based on the directories containing the uncompiled JSPs. The default top-level directory is the directory from which jspc is invoked.
-p name
the name of the target package for all specified JSPs, overriding the default package generation performed by the -d option.
-c name
the target class name of the first JSP compiled. Subsequent JSPs are unaffected.
-uribase dir
the URI directory to which compilations are relative. Applies only to JSP files listed in the command, and not to JSP files specified with -webapp option. This is the location of each JSP file relative to the uriroot. If this cannot be determined, the default is /.
-uriroot dir
the root directory against which URI files are resolved. Applies only to JSP files listed in the command, and not to JSP files specified with -webapp option. If this option is not specified, all parent directories of the first JSP page are searched for a WEB-INF subdirectory. The closest directory to the JSP page that has one is used. If none of the JSP's parent directories have a WEB-INF subdirectory, the directory from which jspc is invoked is used.
compiles the generated servlets into class files.
-v [ level ]
enables verbose mode. The level is optional; the default is 2. Possible level values are:
  • 0 - fatal error messages only
  • 1 - error messages only
  • 2 - error and warning messages only
  • 3 - error, warning, and informational messages
  • 4 - error, warning, informational, and debugging messages
generates separate write calls for each HTML line and comments that describe the location of each line in the JSP file. By default, all adjacent write calls are combined and no location comments are generated.
-die [ code ]
causes the JVM to exit and generates an error return code if a fatal error occurs. If the code is absent or unparsable it defaults to 1.
-webinc file
creates partial servlet mappings for the -webapp option, which can be pasted into a web.xml file.
-webxml file
creates an entire web.xml file for the -webapp option.
-ieplugin class_id
specifies the Java plugin COM class ID for Internet Explorer. Used by the jsp:plugin tags.


 Example 1. Using jspc to compile the JSPs in a web application

The following command compiles a set of JSP files into Java files under Hellodir:

jspc -d Hellodir welcome.jsp shop.jsp checkout.jsp

The following command compiles all the JSP files in the specified webapp into class files under Hellodir:

jspc --d Hellodir --genclass --webapp /path_to_webapp_directory

To use these precompiled JSP in the web application, put the generated files under Hellodir into a JAR file, place the JAR file under WEB-INF/lib and set reload-interval property to --1 in the jsp-config element of the WEB-INF/sun-web.xml file.




Sun Java System Application ServerGo To TopLast Changed March 2004