JSP <c:import> and <jsp:include> difference "go"

Source: Internet
Author: User

<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
  1. Out.write ("
  2. <span style="font-family:webdings;" >out.write ("\r
  3. <br>\r<em><strong>we know how to make SOAP suck less.</strong></em> <br>\r\r
  4. </body>\r
  5. Out.write ("\r<br>\r\r\r<em>we can help.</em> <br><br>\r\rcontact us at:");
  6. Out.write ((java.lang.String) Org.apache.jasper.runtime.PageContextImpl.
  7. Proprietaryevaluate ("${initparam.mainemail}", java.lang.String. Class,
  8. (PageContext) _jspx_page_context, null, false));
  9. Out.write ("\r\r\r</body>

And the dynamic is:

Java code
  1. Out.write ("
  2. <span style="font-family:webdings;" >org.apache.jasper.runtime.jspruntimelibrary.include (Request, Response,
  3. "Header.jsp", out, false);</span>
  4. Out.write ("\r<br>\r\r\r<em>we can help.</em> <br><br>\r\rcontact us at:");
  5. Out.write ((java.lang.String) Org.apache.jasper.runtime.PageContextImpl.
  6. Proprietaryevaluate ("${initparam.mainemail}", java.lang.String. Class,
  7. (PageContext) _jspx_page_context, null, false));
  8. 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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.