Command line procedure to precompile JSPs on Windows for Tomcat6?

血红的双手。 提交于 2020-04-11 03:53:28

问题


tl;dr: How can I run the Tomcat JSP compiler from a Windows command line with verbose or debug logging and compile both the JSP and the Java code?

I want to do a simple test compilation of a JSP for a Tomcat6 environment running on Windows 2008 Server. I'd like to do it with as little installed "stuff" (including Ant) as possible, because I'm going to do this on a build grid that has no other reason to compile any Java code. And I'm going to throw away the compilation result when I'm done - this is just a compilation for an early sanity check. So I really want to avoid "stuff" I don't Need-with-a-capital-N.

It should be pretty easy to run Tomcat's JSP compiler (Jasper, aka JspC) from the command line, but it isn't. I've been able to convice JspC to translate the JSP to Java with the following (buried in a BAT file, but here for simplicity):

"C:\Program Files\Java\jdk1.7.0_17\bin\java" ...
    ... "-classpath" ".\Jasper\lib\jasper.jar;" ...
    ... ".\Jasper\lib\servlet-api.jar;" ...
    ... ".\Jasper\lib\catalina.jar;" ...
    ... ".\Jasper\lib\tomcat-juli.jar;" ...
    ... ".\Jasper\lib\ant.jar;" ...
    ... ".\Jasper\lib\jsp-api.jar;" ...
    ... ".\Jasper\lib\jasper-el.jar;" ...
    ... ".\Jasper\lib\el-api.jar" ...
    ... "org.apache.jasper.JspC" -uriroot ./ -s  -v -l whatever.jsp

And of course I get a nice console message

Aug 20, 2013 12:34:40 PM org.apache.jasper.JspC processFile INFO: Built File: whatever.jsp

and an org\apache\jsp\src\whatever_jsp.java file. But if I add the -compile JspC option, which should compile whatever_jsp.java to whatever_jsp.class, I get no console output, no .class file, and an exit code of 1.

Obviously something's wrong. But since nobody on the net seems to describe how to run JspC except as an Ant task, I'm one clue short of a sixpack. And I can't seem to convince JspC to log at a verbose or DEBUG level, so while I'm sure it's some kind of setup problem, I can't get any diagnostic output.

来源:https://stackoverflow.com/questions/18340673/command-line-procedure-to-precompile-jsps-on-windows-for-tomcat6

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