The jsp:include action includes a resource in a JSP each time it receives a request, Using jsp:include, the included JSP segments have access to the including page's request, session, and application implicit objects, and to any attributes these objects contain. Use the jsp:include action in each location of the file where you need to import resources such as JSP segments from the same web application.

Example below show the page, which includes two JSP segments: header and footer:

////////////// header.jsp: a headerincluded with jsp:include:

<%@page contentType="text/html"%>

      <title><%= request.getParameter("title"%> </title>

////////////// footer.jsp: a footer included with jsp:include:

<%@page contentType="text/html"%>

  Thanks for visiting<br>
  <a href="...">Home</a> | <a href="...">Contacts</a> |
  <a href="...">About ...</a> | <a href="">Resources</a>

////////////// here is a page including two segments:

<%@page contentType="text/html"%>

  <%-- here we pass extra parameter to included page --%>
  <jsp:include flush="true" page="header.jsp">
    <jsp:param name="title" value="Main page"/>

  <body bgcolor="white">
  <table width="660" border="0">
    <%-- Here is page contents --%>

  <table width="660" border="0">
    <tr><td valign="top" align="center">

    <%-- a simple footer --%>
    <jsp:include page="footer.jsp" />