Difference between dynamic and static include In jsp

Source: Internet
Author: User

Answer: implement dynamic INCLUDE with jsp: include action

<Jsp: include page = "embedded DED. jsp" flush = "true"/> It always checks changes in the contained files. It is suitable for inclusion of dynamic pages and can contain parameters.


<% @ Include file = "included.htm" %> static INCLUDE is implemented by using the include pseudo code and will not check the changes to the included files. It is applicable to include static pages.


1. The result of static include is to introduce other jsp into the current jsp.
The dynamic include structure is independent of the two and will not be merged until the output (you can see the java file generated by jsp)

2. it is precisely because of this that the dynamic include jsp file is highly independent. It is a separate jsp file, and the objects and page settings that need to be used must all be created by yourself. Of course, fortunately, it is consistent with the request range of the page that includes it.


Finally, let's look at the content written out of old q.


When you use <jsp: include>, it executed the target in a separate request, and then has DES the output in the including JSP. it doesn' t include the source of the specified Ded target, it should des the output. the means by which that target output is generated is lost.

To do what you're re trying to do, you need to use <% include %> ctictives:

<% @ Include file = "/WEB-INF/jsp/include/header. jsp "%> This will incline the literal text of header. jsp into your page. of course, by doing that, you can no longer pass parameters to it, so you 'd need to set that as a page context attribute (e.g. using <c: set>... But of course you can't use <c: set> until you 've done your include ...).

Essentially, it's not really worth the hassystemic. Taglib declarations are annoying boilerplate, but hard to get rid.

 

Related Article

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.