Compiling Java Server Pages (JSP) in a WAR file to Class files

人走茶凉 提交于 2019-12-12 21:26:33

问题


I have a test WAR file that I generated from source. When I unzip the WAR file I see that the Java classes were compiled to .class files, but the .jsp files were not compiled. I understand this is done at runtime and the .jsp files are eventually converted to .class files.

I developed my WAR file in Tomcat7. I realize this is an odd question. The end goal is to develop a static analysis tool which runs on class files (I cannot read jsp files).

I've read that I can optimize the WAR file and precompile the JSP files into a JAR file that is nested in the WAR file, but I can't figure out how to do it. I'd like to find or create a utility that takes an unoptimized WAR file and generates the JSP class files.


回答1:


Yes, JSPs are normally generated on the fly. In Tomcat, it is done by the Jasper JSP engine.

It is possible to pre-compile them. This article might help: How to pre-compile JSP

It describes how to trigger the pre-compilation from the command line and includes an example Ant file.



来源:https://stackoverflow.com/questions/25735396/compiling-java-server-pages-jsp-in-a-war-file-to-class-files

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