Include Static HTML Page in JSP

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.
includeStatic.jsp
<html>
<head><title>Include Static Page</title></head>
<body>
<H2>Contents of html page display here:</H2>
<%@ include file="static.html" %>
</body>
</html> |
Here is the html page "static.html"
<html>
<head><title>Static HTML Page</title></head>
<body>
<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>
</body>
</html> |
Start Tomcat. Type the url: http://localhost:8080/ServletExample/jsp/includeStatic.jsp
on your browser.
Following output will be displayed:

Download Source Code

|