Home Tutorial Jsp JSPs : include Directives


Share on Google+Share on Google+
JSPs : include Directives
Posted on: December 1, 2012 at 12:00 AM
In this section we are going to discuss the include directives which is one part of Directives.

JSPs : include Directives

In this section we are going to discuss the include directives which is one part of Directives.

include Directives :

Functionality of include directives is to include a file at the time of page translation. The web container merges the content of included files with your JSP pages at translation time.
The include directive is one part of JSP directives. It includes a file during the translation phase. The file can be coded anywhere in your jsp page. It has only one field that is file which specifies the name of the file which you want to include. you can include files which are not in WEB-INF by using include attribute.

Syntax -

<%@ include file="url of file" >

url of file is the actual location of the file you are including. If you just specify a filename with no associated path, the JSP compiler assumes that the file is in the same directory as your JSP.

Example :  In this example we are showing how include directive works.

header.jsp -

<font color="maroon" size="5" style="background-color:silver">
This is your header.You can put header content here.

footer.jsp -

<font color="aqua" size="3" style="background-color: purple;">
This is bottom of your JSP page.

includeDirective.jsp -


<title>Include Directive Example</title>

<%@include file="header.jsp"%>
<div style="padding: 15% 33% 15% 33%; margin: 3px 0 3px 0; border: 1px solid;">
Hello Roseindia! Here you can put your main content.
<%@include file="footer.jsp"%>


Output :


Related Tags for JSPs : include Directives :

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 1, 2012

Recommend the tutorial

Advertisements Advertisements