Difference between include directive and <jsp:include>
1.<jsp:include> provides the benifits of automatic recompliation,smaller class size ,since the code corresponding to the included page is not present in the servlet for every included jsp page and option of specifying the additional request parameter. 2.The <jsp:include> also supports the use of request time attributes valus for dynamically specifying included page which directive does not. 3.the include directive can only incorporate contents from a static document. 4.<jsp:include> can be used to include dynamically generated output eg. from servlets. 5.include directive offers the option of sharing local variables,better run time efficiency. 6.Because the include directive is processed during translation and compilation,it does not impose any restrictions on output buffering.
Submitted by Hemali (hkunjeer @ yahoo . com )
Think of the include directive as a header file of languages like C/C++. When using the include directive, the combined contents of the original JSP page and all its included resources are translated into the same implementation servlet i.e. the contents of the included resource is copy pasted before translation to a servlet. The important thing here is that all this happens during translation time and only static content is supported.
The include action <jsp:include> is almost similar to the include directive except for a few subtle differences. The include action is executed at request time as opposed to translation time. Thus instead of the content of the include file being included in the calling JSP, the output of the JSP is included or passed to the JSPWriter of the calling page. This allows us to include both static and dynamic content into the JSP page. Using the jsp action also allows you to explicitly pass parameters to the included page.