Home Tutorial Jsp JSPs : include Directives

 
 

JSPs : include Directives
Posted on: December 1, 2012 at 12:00 AM
Advertisement
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.
</font> 

footer.jsp -

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

includeDirective.jsp -

<html>

<head>
<title>Include Directive Example</title>
</head>
<body>

<%@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.
</div>
<%@include file="footer.jsp"%>

</body>
</html>

Output :

Advertisement

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
 

 

 

DMCA.com