JSP: include: simple JSP tag used to build dynamic websites
Source: Internet
Author: User
This article is a follow-up article by Java Brett McLaughlin following the first JSP best practices article. In this article, the author demonstrates how to extend the inclusion function of dynamic content in JSP technology. Measure the test taker's knowledge about the differences between static include pseudo commands and dynamic jsp: include elements.
In the previous article in The New JSP best practices series, you learned how to use the JSP include directive to include static content such as headers, footers, and navigation components into Web pages. Like on the server, the JSP include directive allows a page to extract content or data from another page. Listing 1 relives the include directive.
Listing 1. JSP include pseudo commands
<! [CDATA [
<% @ Page language = "java" contentType = "text/html" %>
<Html>
<Head>
<Title> newInstance.com </title>
<Meta http-equiv = "Content-Type"
Content = "text/html; charsets = iso-8859-1"/>
<Link href = "/styles/default.css"
Rel = "stylesheet" type = "text/css"/>
</Head>
<Body>
<% @ Include file = "header. jsp" %>
<% @ Include file = "navigation. jsp" %>
<% @ Include file = "bookshelf. jsp" %>
<% @ Include file = "/mt-blogs/index. jsp" %>
<% @ Include file = "footer. jsp" %>
</Body>
</Html>
]>
What do you need
All the best practices in this series are based on the assumerver Pages technology. To run any of the best practices, you must install JSP-compliant Web containers on your local machine or test server. You also need to use a text editor or IDE to encode JSP pages.
Although include is very suitable for incorporating static content into Web pages, it is not satisfactory for dynamic content. In the previous article, we found this problem when trying to reload the cache file. Unlike most header and footer files, dynamic content changes frequently and must be updated at any time. We will first repeat the limitations of the include directive, and then I will show you how to use the jsp: include tag to expand the JSP inclusion capability.
High-speed cache problems
One disadvantage of the JSP include directive is that it causes the Web browser to cache all pages at a high speed. This makes sense when processing static components such as footer, copyright notice, or a set of static links. These files will not change, so there is no reason for the JSP interpreter to continuously round the data. Wherever possible, high-speed caching should be implemented because it improves the performance of applications.
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.