Include Function in JSP :
As like in other programming JSP also has include function in it ,the include directive is mostly used to includes a file during the
translation phase. This directive says the container to merge the content of
other external files with the current JSP during the translation phase. Include directives can be coded anywhere in your JSP page
Example:
JSP File (header.jsp)
<%!
intpageCount = 0;
voidaddCount() {
pageCount++;
}
%>
<% addCount(); %>
<html>
<head>
<title>nirajanghimireyworkshop.blogspot.com</title>
</head>
<body>
<center>
<h3>This the header part</h3>
<p>You have visited this site <%= pageCount %> times.</p>
</center>
<br/><br/>
JSP File (footer.jsp)
<br/><br/>
<center>
<h3>This is footer part</h3>
</center>
</body>
</html>
JSP File (index.jsp)
<%@ include file="header.jsp" %>
<center>
<h3>This is body part</h3>
<p>nirajanghimireyworkshop.blogspot.com</p>
</center>
<%@ include file="footer.jsp" %>
No comments:
Post a Comment