使用Ant预编译JSP的最佳方法是什么?

时间:2022-05-16 15:54:32

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.

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

2 个解决方案

#1


7  

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

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

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

假设您的类路径在compand行正确,您将运行:

ojspc your.war

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.

战争将得到更新,并在包含预编译JSP的WEB-INF / lib中放置一个jar。请注意,如果您的预编译JSP还应将MAIN_MODE设置为“JUSTRUN”,以获得预编译JSP的额外性能优势。 JUSTRUN设置完成了它的含义,OC4J容器将不再检查更新的.jsp文件。

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

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

一旦熟悉从命令行调用ojspc,您就可以开始使用Oracle提供的ANT任务了。

Within ANT

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

Your project tag should reference the oracle tasks:

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

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

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.

更新02.22.2011您也可以直接使用ojspc jar并避免尝试配置oracle:compileJsp Task,下面的代码接受war文件并在其中预编译JSPS。

 <!-- 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>

the jspPreCompileClassPath defnition looks like this:

jspPreCompileClassPath定义如下所示:

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

#2


2  

I'm not sure what you mean by Oracle's version of Ant but as I understand it you will need the oracle's ant task to do this job. This page explains how to do it. You will be using the apache ant that you download from the apache website, but you need to use Oracle ant task library from Oracle to pre compile JSPs for Oracle.

我不确定Oracle的Ant版本是什么意思,但据我所知,你需要oracle的ant任务来完成这项工作。本页介绍了如何操作。您将使用从apache网站下载的apache ant,但是您需要使用Oracle的Oracle ant任务库来预编译Oracle的JSP。

#1


7  

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

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

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

假设您的类路径在compand行正确,您将运行:

ojspc your.war

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.

战争将得到更新,并在包含预编译JSP的WEB-INF / lib中放置一个jar。请注意,如果您的预编译JSP还应将MAIN_MODE设置为“JUSTRUN”,以获得预编译JSP的额外性能优势。 JUSTRUN设置完成了它的含义,OC4J容器将不再检查更新的.jsp文件。

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

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

一旦熟悉从命令行调用ojspc,您就可以开始使用Oracle提供的ANT任务了。

Within ANT

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

Your project tag should reference the oracle tasks:

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

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

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.

更新02.22.2011您也可以直接使用ojspc jar并避免尝试配置oracle:compileJsp Task,下面的代码接受war文件并在其中预编译JSPS。

 <!-- 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>

the jspPreCompileClassPath defnition looks like this:

jspPreCompileClassPath定义如下所示:

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

#2


2  

I'm not sure what you mean by Oracle's version of Ant but as I understand it you will need the oracle's ant task to do this job. This page explains how to do it. You will be using the apache ant that you download from the apache website, but you need to use Oracle ant task library from Oracle to pre compile JSPs for Oracle.

我不确定Oracle的Ant版本是什么意思,但据我所知,你需要oracle的ant任务来完成这项工作。本页介绍了如何操作。您将使用从apache网站下载的apache ant,但是您需要使用Oracle的Oracle ant任务库来预编译Oracle的JSP。