Including content of another file in a JSP file
The JSP include directive is used to include content of another source file into a JSP file. The content of file which includes external file is merged with content of the external file. The general syntax for including content of another file is as follows:
Parameters can also be passed to the included file.
Here address.jsp file is created. It displays address and email of user that are provided to it. File named "including.jsp" includes the "address.jsp file", passes required parameter to it.
<% out.println("<p>Address: "+request.getParameter("address")+"</p>"); out.println("<p>Email: "+request.getParameter("email")+"</p>"); %>
<html> <body> <p>This is first paragraph</p> <p>This is second paragraph</p> <p> This paragraph is from another file. <p> <jsp:include page="address.jsp"> <jsp:param name="address" value="Baneshwor"/> <jsp:param name="email" value="firstname.lastname@example.org"/> </jsp:include> </p> </p> </body> </html>