How to include one JSP in another JSP Example

Hey guys in this article, you will learn about how to include JSP page in another JSP with easy to understand example

Read More:


To include JSP in another JSP file, we will use <jsp:include /> tag. It has a attribute page which contains name of the JSP file.

To include .html file

<jsp:include page="footer.html" />

To include .jsp file

<jsp:include page="JSPHeader.jsp" />

Complete Example

Follow the below steps to understand the complete example

Create a Project

You can check the following post to create a new Dynamic Web Project

Create a JSP file for Header

Create JSPHeader.jsp file under WebContent and add the following content

	<p>This is header</p>

Create a HTML file for Footer

Create footer.html file under WebContent and add the following content

	<p>This is footer</p>

Create a JSP file for Landing page

Create JSPTest.jsp file under WebContent and add the following content

<%@page import="in.bushansirgur.Test"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html>
<meta charset="ISO-8859-1">
<title>Insert title here</title>

	<jsp:include page="JSPHeader.jsp" />
	<p>Main content</p>
	<jsp:include page="footer.html" />

Run the file

Right click on the File, choose Run As, choose Run on Server. It will open in a default web browser, you will see the following content


That’s it for this post, if you like this post, please share this post with your friends and collogues and also share this on your social media profiles.

Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

Leave a Reply