使用 Ant 预编译 JSP 的最佳方法是什么 [英] What is the best way to precompile JSPs using Ant

查看:37
本文介绍了使用 Ant 预编译 JSP 的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出使用 Ant 预编译将部署到 Oracle 应用服务器的 JSP 的最佳方法.即使我正在部署到 Oracle 应用服务器,我也希望避免使用 Oracle 版本的 Ant.

I am trying to figure out the best way to use Ant to precompile JSPs that will be deployed to an Oracle application server. Even though I am deploying to an Oracle app server I would like to avoid using Oracle's version of Ant.

推荐答案

Oracle 的 JSP 编译器可在 ORACLE_HOME/j2ee/home/jsp/bin/ojspc 的 oc4j 安装中使用

Oracle's JSP compiler is available in your oc4j install at ORACLE_HOME/j2ee/home/jsp/bin/ojspc

假设您的类路径在您将运行的压缩行中是正确的:

Assuming your classpath is correct at the compand line you would run:

ojspc your.war

ojspc your.war

war 将得到更新并在包含预编译 JSP 的 WEB-INF/lib 中放置一个 jar.请注意,如果您预编译 JSP,您还应该将 MAIN_MODE 设置为 'JUSTRUN' 以获得预编译 JSP 的额外性能优势.JUSTRUN 设置执行它所暗示的操作,OC4J 容器将不再检查更新的 .jsp 文件.

The war will get updated and place a jar in the WEB-INF/lib containing the pre-compiled JSPs. Note that if your pre-compiling JSPs you should also set the MAIN_MODE to 'JUSTRUN' to get the additional performance benefit of pre-compiling your JSPs. The JUSTRUN setting does what it implies, the OC4J container will no longer check for updated .jsp files.

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>oracle.jsp.runtimev2.JspServlet</servlet-class>
    <init-param>
      <param-name>main_mode</param-name>
      <param-value>justrun</param-value>
    </init-param>
</servlet>

在您熟悉从命令行调用 ojspc 之后,您就可以开始使用 Oracle 提供的 ANT 任务了.

Once your comfortable with calling ojspc from the command line You can then begin to use the ANT tasks provided by Oracle.

在 ANT 内

<oracle:compileJsp file="dist/war/before-${app}war"
        verbose="false"
        output="dist/war/${app}.war" />

您的项目标签应引用 oracle 任务:

<project name="your-name" default="compile" basedir="."  xmlns:oracle="antlib:oracle">
...
</project>

2011 年 2 月 22 日更新您也可以直接使用 ojspc jar 并避免尝试配置 oracle:compileJsp 任务,下面的代码采用一个 war 文件并在其中预编译 JSPS.

Update 02.22.2011 You can also just work with the ojspc jar directly and avoid trying to configure the oracle:compileJsp Task, the code below takes a war file and pre-compiles the JSPS in it.

 <!-- Now Precompile the War File (see entry in <project> tag ) -->
    <java jar="${env.ORACLE_HOME}/j2ee/home/ojspc.jar" classpathref="jspPreCompileClassPath" fork="true">
        <arg value="-addClasspath"/>
        <arg pathref="classpath"/>
        <arg line="'${dist}/war/a-war-file.war'"/>
    </java>

jspPreCompileClassPath 定义如下所示:

the jspPreCompileClassPath defnition looks like this:

  <path id="jspPreCompileClassPath">
    <path location="${env.ORACLE_HOME}/j2ee/home/lib/pcl.jar"/>
    <path location="${env.ORACLE_HOME}/j2ee/home/lib/ojsp.jar"/>
    <path location="${env.ORACLE_HOME}/j2ee/home/lib/oc4j-internal.jar"/>
    <path location="${env.ORACLE_HOME}/j2ee/home/lib/servlet.jar"/>
    <path location="${env.ORACLE_HOME}/j2ee/home/lib/commons-el.jar"/>
    <path location="${env.ORACLE_HOME}/j2ee/home/lib/bcel.jar"/>
    <path location="${env.ORACLE_HOME}/lib/xmlparserv2.jar"/>
    <path location="${env.ORACLE_HOME}/j2ee/home/lib/oc4j-schemas.jar"/>
    <path location="${env.ORACLE_HOME}/j2ee/home/jsp/lib/taglib/ojsputil.jar"/>
  </path>

这篇关于使用 Ant 预编译 JSP 的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆