JSP include Directive
JSP include Directive
- The include directive is used during translation phase.
- The include directive is tells container to merge the content of other external files with the current JSP during the translation phase.
- The include directive can be used anywhere in the JSP page.
- File name specified inside the include directive is relative URL.
Syntax :
Following statement is used for include directive :
<%@ include file="relative_url" >
XML equivalent of the above syntax is - :
<jsp:directive.include file="relative_url" />
Note : If no path is specified then JSP compiler will assumes that the file is in the same directory as your JSP.
Example :
Consider header.jsp file -
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>main.jsp</title> </head> <body> <h2>Header Section</h2> </body> </html>
Consider main.jsp file -
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>main.jsp</title> </head> <body> <%@ include file="header.jsp" %> </body> </html>