JSP Include Example

JSP Include Example explains step by step details of dynamically including a jsp page

Consider an example where we are including a page (welcome.jsp) inside include.jsp.

The jsp:include Tag includes the response or output of the pages dynamically. By using jsp:include tag, the included files are compiled / processed separately and included with final response only at runtime. ie; it is also called dynamic include

that's why it is also called as jsp dynamic include

You can see the below example, which is demonstrating How to include JSP pages dynamically

Note

You can also find following related tutorials on this blog

1) JSP Redirect Example 2) JSP Forward Example

include.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>jsp:include example</title>
</head>
<body>
    This is a page<br/>
    <jsp:include page="welcome.jsp" />
</body>
</html>

welcome.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
</head>
<body>
    Welcome Dynamic Include Is Working Now
</body>
</html>
Output
JSP Include Example








Your email address will not be published. Required fields are marked *