Share on Google+Share on Google+

Include Static HTML Page in JSP

This example shows how to include static html page in jsp.

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.


  <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:

Download Source Code


Posted on: July 11, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.

Discuss: Include Static HTML Page in JSP   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
anantha lakshmi.m
December 23, 2012

i want basic cncpts of jsp to create web pages