Execute JSP with Jetty 7.3 without javac

久未见 提交于 2019-12-11 09:27:07

问题


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.

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.

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>

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.


回答1:


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

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.

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.

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.



来源:https://stackoverflow.com/questions/8141813/execute-jsp-with-jetty-7-3-without-javac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!