What is the difference between include action and include directive in JSP?

Answered

What is the difference between include action and include directive in JSP?

Ninja Asked on 18th September 2018 in Jsp.
Add Comment
1 Answer(s)
Best answer

<%@ include file=”filename” %> is the JSP include directive. The include directive, includes the content of the specified file during the translation phase–when the page is converted to a servlet. At JSP page translation time, the content of the file given in the include directive is ‘pasted’ as it is, in the place where the JSP include directive is used.

The include directive is used to statically insert the contents of a resource into the current JSP. Use the include directive if the file changes rarely. Generally JSP include directive is used to include header banners and footers.

<jsp:include page=”relativeURL” /> is the JSP standard include action element. The include action, includes the response generated by executing the specified page (a JSP page or a servlet) during the request processing phase–when the page is requested by a user. At runtime, the included file will be ‘executed’ and the result content will be included with the source JSP page. The include standard action enables the current JSP page to include a static or a dynamic resource at runtime.

Use the include action only for content that changes often, and if which page to include cannot be decided until the main page is requested.

Ninja Answered on 18th September 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.