Difference Between Static Include And Dynamic Include
Difference Between Static Include And Dynamic Include Example explains what are the Differences Between Static Include And Dynamic Include In JSP with example
You can also see an examples of jsp:forward and jsp:include examples below
1) JSP Forward Example
2) JSP Include Example
Static Include Example
<%@include> the contents of each file will be included at compilation phase. Static includes are much faster than dynamic includes.
include.jsp
<html> <head> <title>JSP Static Include Example</title> </head> <body> The current date and time are <%@ include file="date.jsp"%> </body> </html>
date.jsp
<%@ page import="java.util.*" %> <%= (new java.util.Date() ).toLocaleString() %>
Output
Dynamic Include Example
The "jsp:include"
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>