This example shows how to include static html page in jsp.
In JSP, there are two ways to include another web resource.
1. include directive and
2. jsp:include element.
Using include directive inserts text of another file and processed when the JSP is translated into a servlet class. So you can use include directive when any chunk of code is needed to be reused.
In this example <%@ include file="static.html" %> tag is used to include html page. The following includeStatic.jsp page shows the include tag.
<head><title>Include Static Page</title></head>
<H2>Contents of html page display here:</H2>
<%@ include file="static.html" %>
Here is the html page "static.html"
<head><title>Static HTML Page</title></head>
<H3>This is the html page:</H3>
<b><font color='blue'> My name is sandeep kumar suman</font></b><br>
<b><font color='blue'> Roseindia Technology Pvt Ltd, New Delhi</font></b>
Start Tomcat. Type the url: http://localhost:8080/ServletExample/jsp/includeStatic.jsp
on your browser.
Following output will be displayed:
Posted on: July 11, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles