Another form and difference of include
Let's briefly say the two forms of include:
<% include file= ""%>: for static inclusion (load)
<jsp:include page= "" flush= "true"/>: for dynamic inclusion (loading)
Simply explain the static inclusions and dynamic inclusions:
Static include: The JSP compiler compiles the time already contains the corresponding file, generates a Java_servlet, the corresponding servlet file contains the included page, and then Javac compiled into a class file, when the JVM is running, a page can not be passed the parameter ( is equivalent to sending himself a reference), meaningless.
Dynamic inclusion: When the JSP compiler compiles, loading the page and being clamped on the page will be parsed into two java_servlet files, Javac compiler will compile two times, generate two class files and then in the process of running the JVM, this time contains files to call the included class file (Note: JSP tags need to close themselves, do not forget to close the slash)
Here is an analysis diagram of my own drawing:
To give you some examples of reference:
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>jsp:include</title>
<body bgcolor= "White" >
<font color= "Red" >
<%@ include file= "file name"%>
<%= request + "--1--" + "<br>"%>
<jsp:include page= "file name" flush= "true"/>
<%= request + "--1--" + "<br/>"%>
<jsp:include page= "filename? username= ' 123 '" flush= "true"/>
</font>
</body>
As you can see from the example above, because the build is two different servlet files--Different class---> so each servlet has its own request object, Not the same one. But the first one is to generate a servlet so it's the same request.
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding= "Utf-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title>TestBar.jsp</title>
<body>
<table width= "100%" >
<tr><td><%@ include file= "file name"%></td></tr>
<%=request.getparameter ("username")%>
<tr><td><% out.println ("<p> This is the user display area </p>");%></td></tr>
</table>
</body>
The above example shows that after two source files are generated, it is the same page, and then the same request is used on this page and the same request object is received.
Two forms and introductions of include