How can I get the JSP container to realize when I've modified a file that was included using <%@ include file="XXX" %>, and to recompile files that include it?

Alessandro A. Garbagnati

I realized that if I make changes to XXX above then for the changes to take effect in the jsp at runtime, I need to do the following:

  • Wipe out the tomcat/work/<whatever> directory
  • Restart tomcat
Is that a problem? Am I missing something?
You don't have to do all that process, but yoiu have to 'trick' the servlet container. The easiest way to achieve what you need is to just re-save the file that contains the include directive. This resaving operation will force the servlet container to recompile the JSP. No need to restart, in this case.

The reason why this is happening it's pretty simple. The include directive (<%@ include ...>) it's a static include. What it does, is to get the content of the file to include and it puts it inside the JSP, as part of the page itself. This happens during the compilation process and once it is compiled, the included file isn't checked anymore.

If you want a dynamic include, that takes care of the changes of the included file, maybe you should consider using the <jsp:include/> tag. In that case the file is not statically included into the page, so every change to it's not ignored.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact