JSP Include Directive


The include directive is made in use to comprise the contents of any resource it can be a JSP file, Html file or text file, or any other. At page translation time, The include directive contains the original content of the included resource (although, the JSP page is interpreted only one time so it is good to contain static resources).

Benefits of Include Directive

Code Reusability

Syntax of the Include Directive

<%@ include file="resourceName" %> 

Example of Include Directive

We are including the content of the header.html file in the below given example. You have to generate a header.html file to run this example.


<%@ include file="header.html" %>  
Today is: <%= java.util.Calendar.getInstance().getTime() %>  


Note: The actual page size grows at the runtime because include directives include the original content.