在没有Javac的情况下使用Jetty 7.3执行JSP [英] Execute JSP with Jetty 7.3 without javac

查看:96
本文介绍了在没有Javac的情况下使用Jetty 7.3执行JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题: 我有一个由Jetty webserver v 7.3提供服务​​的Web应用程序.我在应用程序中有一个JSP页面.当我在安装了JDK(具有javac)的系统上运行Jetty时,一切正常.我想将此移植到具有JRE(没有javac)的系统上.当我运行码头时,我得到一个错误.

The problem: I have a web application which is served by Jetty webserver v 7.3. I have a JSP page in the application. When I run the Jetty on system which has JDK(has javac) installed everything works fine. I want to port this to a system which has JRE(does not have javac). When I run the Jetty I get an error.

解决方案: 将JSP预编译到Servlet中.生成包含该servlet的应用程序war文件.让Jetty在运行时代替编译和执行JSP来执行Servlet.

The solution: Pre-compile the JSP into Servlet. Generate application war file which includes this servlet. Let jetty execute the Servlet in place of compiling and executing JSP at runtime.

我试图使用JSPC ant目标来预编译JSP.但是它正在生成一个空的.java文件.我的目标代码如下.

I tried to pre-compile JSP using JSPC ant target. But it is generating an empty .java file. My target code is as follows.

<jspc srcdir="${web.dir}"
          destdir="${build.classes.dir}"
          package="x.y.z"
          verbose="9"
          classpathref="project.class.path">
      <include name="**/index.jsp"/>
    </jspc>

请建议我采取适当的方法.如果我的方法是正确的,请指出我在配置ant任务时犯的错误.

Kindly suggest me a proper approach. If my approach is correct, kindly point out the mistake that I am making in configuring the ant task.

推荐答案

不要使用ant提供的jspc任务.它已弃用,易碎,并且仅在安装了Tomcat 4(某些版本)的情况下可以使用.

Don't use the ant supplied jspc task. It is deprecated, flaky, and only worked with Tomcat 4 installed (certain versions).

相反,请安装Tomcat(哪种版本最能支持与您部署的Jetty相同的JSP/Servlet规范),然后通过Tomcat提供的Ant任务调用Jasper编译器. 此处提供了Tomcat 5的示例.

Instead, install Tomcat (whichever version best supports the same JSP/Servlet specs as your deployed Jetty) and call the Jasper compiler via the Tomcat provided Ant task. An example for Tomcat 5 is available here.

请注意,一旦将JSP页面编译为Servlet,然后将Servlet编译为类,等等.在Jetty部署环境中,您不需要任何这种构建环境".

Note that once the JSP pages are compiled to Servlets, the Servlets are compiled to classes, etc. You don't need any of this "build environment" in your Jetty deployment environment.

也请注意,蚂蚁结尾处的注释提供了jspc任务.我不知道它是否仍然有用,但是很有趣.

Also note that the commentary near the end of the ant supplied jspc task. I don't know if it is still relevant, but it is interesting.

这篇关于在没有Javac的情况下使用Jetty 7.3执行JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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