jspjsp-tagsjspinclude

JSP include directive tag


JSP include directive tag:

By my understanding,when you include a file by DIRECTIVE tag,any change made in the included file will not be processed unless the including file is recompiled. But when i am making a change in the included file,the changes are shown when i just press refresh!How is it possible since i dint recompile the including file?The changes should not be shown.

I just made a change to the included file,saved it and then refreshed the browser and the change is being shown!


Solution

  • It really depends on the application server you are using.

    For reference, the JSP specification states in section JSP.1.10.3:

    A JSP container can include a mechanism for being notified if an included file changes, so the container can recompile the JSP page. However, the JSP 2.2 specification does not have a way of directing the JSP container that included files have changed.

    If you are using WebSphere Application Server, by default, an include via the include directive will not cause the parent JSP to be recompiled if only the child (included jsp) has changed. If a user wants that behavior then they would set the "trackDependencies" JSP attribute to "true" in the application's WEB-INF/ibm-web-ext.xml file, which is false by default.

    If you are using Tomcat, then I believe this is the expected behavior when you are running in development mode (default) with Jasper 2.
    The Tomcat docs here: http://tomcat.apache.org/tomcat-8.0-doc/jasper-howto.html state that:

    Recompile JSP when included page changes - Jasper 2 can now detect when a page included at compile time from a JSP has changed and then recompile the parent JSP.

    If you want to turn off that behavior then I believe you would need to set the development to false tomcat_home/conf/web.xml file, like this (in the jsp section of the file):

    <init-param>
     <param-name>development</param-name>
     <param-value>false</param-value>
    </init-param>