Thursday 6 March 2014

JSP Include directive and Dynamic include

The interesting difference between the include directive and the dynamic include is that the former is a static import and the latter is a dynamic import. 

To explain, the include directive is similar to a macro call while the dynamic include is like a function call. While a macro call simply inserts or includes the contents of the macro definition in the body of the program where it is called at compile-time, a function call is more than a mere include. Function calls perform some kind of computation on the data that is passed to them as arguments. 

In our own context of JSPs, use of the static import using <@include file = " " /> essentially inserts the contents of the file specified at that place and compiles it with the JSP into a servlet. The dynamic import using <jsp: include page = " " / > on the other hand, compiles the included JSP page as a separate JSP and embeds a call to it at the point of dynamic import statement.


No comments:

Post a Comment