<jsp:include page= ""/> Action and <c:import url= ""/> jstl tag are dynamically loaded. But C:import is more flexible. Jsp:include can only include pages under the current web app, while c:import loads content from an external container.
The most fundamental difference between dynamic loading and static loading is that the servlet generated by the JSP is different. The _jspservice () code for static (include directive) and dynamic (include action) under Tomcat is as follows:
Java code
- Out.write ("
- <span style="font-family:webdings;" >out.write ("\r
- <br>\r<em><strong>we know how to make SOAP suck less.</strong></em> <br>\r\r
- </body>\r
- Out.write ("\r<br>\r\r\r<em>we can help.</em> <br><br>\r\rcontact us at:");
- Out.write ((java.lang.String) Org.apache.jasper.runtime.PageContextImpl.
- Proprietaryevaluate ("${initparam.mainemail}", java.lang.String. Class,
- (PageContext) _jspx_page_context, null, false));
- Out.write ("\r\r\r</body>
And the dynamic is:
Java code
- Out.write ("
- <span style="font-family:webdings;" >org.apache.jasper.runtime.jspruntimelibrary.include (Request, Response,
- "Header.jsp", out, false);</span>
- Out.write ("\r<br>\r\r\r<em>we can help.</em> <br><br>\r\rcontact us at:");
- Out.write ((java.lang.String) Org.apache.jasper.runtime.PageContextImpl.
- Proprietaryevaluate ("${initparam.mainemail}", java.lang.String. Class,
- (PageContext) _jspx_page_context, null, false));
- Out.write ("\r\r\r</body>
You can see that the static is that the page that will include is written directly in the servlet, so that when the servlet is generated, it cannot be modified. Dynamic is different, the page is imported by the runtime.
In addition, Jsp:include and C:import can use Jsp:param and C:param to set parameters to control which pages to include.
JSP <c:import> and <jsp:include> difference "go"