Compiling JSPs Using the Command-Line Compiler---官方

Web Server provides the following ways of compiling JSP 2.1-compliant source files into servlets:

  • JSP are automatically compiled at runtime.
  • The jspc command-line tool, described in this section, enables you to precompile JSPs at the command line.

You must disable dynamic reloading of JSP when deploying a web application archive that has precompiled JSP without the correspondingjsp source files. To do this, set the reload-interval property to -1 in the jsp-config element of the sun-web.xml file. For more information, see JSP Element.

The jspc command-line tool is located under install_dir/bin. The format of the jspc command is as follows:

jspc [options] file_specifier

The following table shows what file_specifier can contain in the jspc command.

Table 5–1 File Specifiers for the jspc Command

 

File Specifier


Description


files


One or more JSP files to be compiled.


-webappdir


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 extract such files to an open directory structure.

The following table shows the basic options for the jspc command.

Table 5–2 Basic jspc Options

 

Option


Description


-help


Enables quiet mode (same as -v0). Only fatal error messages are displayed.


-v


Verbose mode.


-d dir


Specifies 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.


-l


Specifies the name of the JSP on failure.


-s


Specifies the name of the JSP on success.


-p name


Specifies the name of the target package for all specified JSPs, overriding the default package generation performed by the -d option.


-c name


Specifies the target class name of the first JSP compiled. Subsequent JSPs are unaffected.


-mapped


Generates separate write() calls for each HTML line in the JSP.


die(#)


Generates an error return code (#) on fatal errors (default 1).


-uribase dir


Specifies the URI directory to which compilations are relative. Applies only to explicitly declared JSP files.

This path is the location of each JSP file relative to the uriroot. If this location cannot be determined, the default is /.


-uriroot 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 extract such files to an open directory structure.


-compile


Compiles the generated servlets.


-genclass


Generates class files in addition to Java files.


-webinc file


Creates a partial servlet mappings in the file.


-web.xml file


Creates a complete web.xml structure in the file.


-ieplugin clsid


Java Plug-in classid for Internet Explorer.


classpath path


Overrides the java.class.path system property


xpoweredBy


Add the X-Powered-By response header.


-trimSpaces


Trims spaces in text templates between actions and directives.


-smap


Generates SMAP info for JSR 45 debugging.


-dumpsmap


Dumps SMAP info for JSR45 debugging into a file.


-compilerSourceVMrelease


Provides source compatibility with specified JDKTM release.


-compilerTargetVMrelease


Generates class files for specified VM version.

For example, this command compiles the hello JSP file and writes the compiled JSP under hellodir:

jspc -d hellodir -genclass hello.jsp

This command compiles all of the JSP files in the web application under webappdir into class files under jspclassdir:

jspc -d jspclassdir -genclass -webapp webappdir

To use either of these precompiled JSPs in a web application, put the classes under hellodir or jspclassdir into a JAR file, place the JAR file under WEB-INF/lib, and set the reload-interval property to -1 in the sun-web.xml file.

Package Names Generated by the JSP Compiler

When a JSP is compiled, a package is created for it. The package name starts with jspc. For example, the generated package name for~/SOURCE/JSP/myjsps/hello.jsp is precompiled as jspc -webapp ~/SOURCE -d ~/test1/test2/test3. The generated servlet is located in ~/test1/test2/test3/org/apache/jsp/JSP/myjsps/hello_jsp.java and defined in org.apache.jsp.JSP.myjsps. The path for hello.jsp is derived from the directory in which the JSP is located.

In another example, the same hello.jsp is precompiled using the —p option, and is precompiled as jspc -webapp ~/SOURCE -d ~/test1/test2/test3 -p app1.app2.app3. The generated servlet is located in~/test1/test2/test3/app1/app2/app3/JSP/myjsps/hello_jsp.java and defined inside package app1.app2.app3.JSP.myjsps. Note that the package specified with the -p option (app1.app2.app3) overrides the standard org.apache.jsp but does not affect the package derived from the directory in which the JSP is located. Also, note that the -d option does not affect on the generated package name.

Other JSP Configuration Parameters

For information about the various JSP configuration parameters you can use, see the section jsp-config Element. The JSP compiler uses the default values for parameters that are not included in the file.

原文地址:https://docs.oracle.com/cd/E19146-01/821-0790/abxcc/index.html

时间: 2024-10-26 16:10:56

Compiling JSPs Using the Command-Line Compiler---官方的相关文章

Building QT projects from the command line

/************************************************************************ * Building QT projects from the command line * 说明: * 很多时候都是通过Qtcreator进行项目的创建以及编译,但是有时候可能 * 会遇到一些编译小问题,这时候命令行创建工程.编译工程可以作为测试.验证 * 的一种手段. * * 2016-3-2 深圳 南山平山村 曾剑锋 *************

scrapy系列教程二——命令行工具(Command line tools)

1.命令行工具(Command line tools) Scrapy是通过Scrapy命令行工具进行控制的.这里我们称之为 “Scrapy tool” 以用来和子命令进行区分. 对于子命令,我们称为 “command” 或者 “Scrapy commands”.Scrapy tool 针对不同的目的提供了多个命令,每个命令支持不同的参数和选项. 2.常用命令 官方命令行说明文档 http://scrapy-chs.readthedocs.org/zh_CN/latest/topics/comma

MysqL5.7在使用mysqldump命令备份数据库报错:mysqldump: [Warning] Using a password on the command line interface can be insecure.

在阿里云服务器增加一个shell脚本定时备份数据库脚本执行任务时,测试性的执行了备份命令,如下 [[email protected] mysql_bak]# /usr/local/mysql/bin/mysqldump -uroot -pmyServerPwd# dateabase > /data/mysql_bak/bak_test.sql 在执行完了命令本该在指定的目录下出现bak_test.sql文件,然而并没有生成,报了一行错误.这个问题应该是在MySQL5.6+版本的时候就有出现,可能

在WSL中安装swool报错 error: unrecognized command line option '-V' 的解决方法

Windows Subsystem for Linux Ubuntu中使用pecl安装swool时遇到错误"error: C compiler cannot create executables"."error: unrecognized command line option '-V'" 解决方法 先看解决方法, 将gcc版本降低到4.8即可,因为高版本gcc取消了-V参数: sudo apt install gcc-4.8 -y sudo update-alte

【413】C 语言 Command line

Command-Line Arguments All the executable programs above have a main(void) program more generally, executables take arguments on the command line these enter the program via parameters 切换行号显示 1 int main(int argc, char *argv[]) For example: prompt$ ./

Can't use Subversion command line client: svn

使用Intellij IDEA的svn时提示出错:Can't use Subversion command line client: svn. 当我在使用svn,Checkout一个项目后,然后将其导入到Intellij idea中,出现这样的报错!经过google后,发现了问题,我的问题是:我安装的TortoiseSVN工具,本身是带有command-line功能的(我没有安装)如图: 所以报这个错误.如果安装的TortoiseSVN工具,本身是不带有command-line功能的,必须要安装

解决MySQL5.6 Warning: Using a password on the command line interface can be insecure

MySQL5.6在使用名文的密码登陆时,会出现:Warning: Using a password on the command line interface can be insecure 当然这样对于平常的登陆会无所谓,如果在脚本里使用使用的话,就会有问题: 解决这种问题的方法是需要在my.cnf中配置即可: 在my.cnf中加入如下配置 [mysqladump] user=my_name password=my_pass 重启MySQL 即可 以后再使用mysqldump命令就不需要加上任

How to build .apk file from command line(转)

How to build .apk file from command line Created on Wednesday, 29 June 2011 14:32 If you don’t want to install a number of programs for building your Android project, this article is for you. You will need only JDK, the Android SDK platform tools and

Command line option syntax error.type Command /? for help

电脑装思维导图的时候,报错显示"Command line option syntax error.Type Command /? for help."就查了一下,原来是系统没有C++2005,需要安装,就上网下载了一个vcredist_x86.exe,但是双击安装,仍然出现这个错误. 没办法,接着上网查吧,是什么原因呢?网上说是因为该文件安装不支持中文安装路径,然后我就把文件夹改成了英文名称的,但是双击还是出现这个错误.可能有的人用这种方法成功了吧~本着没有解决不了的问题的思想,接着奋