JSP 的生命周期、编译和替换
我很难找到有关此问题的整体信息,特别是有关 JSP 代码在 tomcat 中的位置的信息。
我有一个应用程序并为其开发。我远程调试和更改代码。这不会将代码发布到远程计算机。所以,我尝试将JSP文件复制过来。这不会改变任何事情,在调试时,我可以看到调试器跳转到不包含代码的行。
很好。我使用 Lambda Probe 删除工作目录,甚至显式重新编译所有 JSP,包括我一开始想要更改的 JSP。我可以查看代码,甚至是编译后的 servlet 代码,所有这些都列出了我的更改。然而,再次运行调试器并尝试调试我更改的代码仍然跳到行,就好像我根本没有更改我的代码一样。
这迫使我进行完整部署:我编译整个 WAR 文件,将其复制到服务器(它被部署),我的程序启动,我需要大约 10 分钟才能达到之前的相同点。
tomcat 到底在工作目录旁边缓存/存放我的 JSP 代码在哪里?是否有可能通过调试器“即时”更改代码?我知道只要我不更改方法签名,类就可以实现,但我在 JSP 文件中无助地与同样的想法作斗争。
任何帮助将不胜感激,无论是解释网站的链接还是解释本身。
谢谢。
I'm having trouble to either find information about this as a whole and specifically about the placement of JSP code in tomcat.
I have an application and develop for it. I' remotely debugging and changing code. This will not publish the code to the remote machine. So, I try to copy the JSP file over. This does not change a thing, when debugging, I can see that the debugger jumps on lines that contain no code.
Very well. I use Lambda Probe to delete the work directory and even explicitly recompile all JSPs, including the one I wanted to change in the first place. I can view the code and even the compiled servlet code, all listing my changes. However, running the debugger again and trying to debug my changed code STILL jumps to lines as if I didn't change my code at all.
This forces me to do a full deployment: I compile a whole WAR file, copy it to the server (it gets deployed), my program starts up, and I need about 10 minutes to get to the same point I was before.
Where the heck does tomcat cache/deposit the code of my JSPs beside the work directory? Is it at all possible to change code "on the fly" via the debugger? I know it's possible for classes as long as I do not change the method signature, but I am helplessly struggling with the same idea in JSP files.
Any help will be appreciated, be it links to explaining sites or explanations itself.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您应该自动化构建,可能使用 ant。您需要能够快速部署。
如果普通 Tomcat 检测到更改(通常从文件修改日期开始),它将重新加载 JSP。因此请确保 tomcat 配置不会阻止这种情况发生。看看 http://tomcat.apache.org/tomcat -5.5-doc/jasper-howto.html#Production_Configuration
要删除已编译的 JSP(从而强制 tomcat 根据请求重新编译 JSP),您可以删除
tomcat/work
下的相应文件夹,例如tomcat/work/Catalina/www.example.com/_/org
在该目录下可以找到编译后的 JSP 和标记文件。First of all you should automate your build, probably using ant. You need to be able to deploy quickly.
A vanilla tomcat will reload JSPs if it detects changes (usually from the file modification date). So make sure that the tomcat configuration does not prevent this happening. Have a look at http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html#Production_Configuration
To remove the compiled JSPs (thus forcing tomcat to recompile JSPs upon request) you can delete the appropriate folder under
tomcat/work
, e.gtomcat/work/Catalina/www.example.com/_/org
under which you can find the compiled JSP and tag files.