There is good discussion on Stack Overflow about their difference found here. It roughly says that <jsp:include>
is dynamic, while <@ include>
is static. Yet, I have some questions.
1. st question
Say I use <jsp include>
to include header.jsp file. It would run like this: Container compiles my JSP file and during runtime it calls header.jsp, which would also get compiled. So now it uses its content as a response to my JSP file (and combines it). But how is it dynamic? What happens if I change header.jsp? As it had already been compiled, it won't see any changes. So does <jsp: include page="header.jsp"/>
simply compiles header.jsp every single time to maintain its dynamic behavior? Or there is different approach that "tells" Container to recompile it?
2. nd question
Whatever the answer on first question, I understand that it is dynamic, no matter how does it do it. Well, until I came across this picture from Head First JSP and Servlets.
Does this now mean that even <@ include>
can be dynamic, as well? If I am making an app in Tomcat5 (friendly container), why would I care if some other Container (older versions) aren't friendly? I mean, I would use one Container and stick to it, not move my app around other Containers, right? So why I don't simply always use <@ include>
, let Container "deal" with any changes in included file, plus I don't get performance hit of using RequestDispatcher every single request (like <jsp:include
has).