This article is the first part of a new series of articles on JSP best practices. It introduces the assumerver Pages include mechanism. Follow Java programming expert Brett McLaughlin to learn how to use include to add static header files and footer files to your website or Web application pages.
Read the latest Best Practices series in the Java area. If you have read the previous series of articles, you will know that the best practices are designed to help you quickly understand the useful aspects of various Java technologies. This series of best practices specifically discusses the assumerver Pages (JSP) technology, which is one of the core J2EE technologies.
In short, JSP technology is a tool for building Web pages or Web application interfaces on the Java platform. JSP technology allows us to do the following: dynamically respond to request data, display complex XML and HTML, and create interesting, dynamic-driven websites. In this series, you will learn some basic knowledge about Using JSP technology to build websites. I will introduce you to the most common JSP mechanisms, through which you will understand basic Web development technologies, such as creating templates, operating dynamic content, image hosting, and creating a utility code library.
This is the first article in this series. In this article, we will focus on the JSP include mechanism, which allows us to "pull" the content of the local HTML page. We will first introduce some background knowledge about the development of Web Page include, especially the use of the framework and server-side include. Then, I will show you how to use the JSP include mechanism to add uniform header files and footer files to Web pages or Web application screens.
JSP Best Practices Series
This series of articles does not intend to fully introduce JSP technology, nor are they intended to serve as a guide to how to build special types of applications. On the contrary, each part of the series focuses on one aspect of JSP-based programming and divides it into small fragments. For more information about JSP technology or more in-depth research on how to use it for special results, see references.
What do you need
All the best practices in this series are based on the assumerver Pages technology. To run any practice, you need to set JSP-compliant Web containers on the local machine or test server, such as Apache Tomcat. You also need to use a text editor or IDE To write JSP page code. See references to obtain links to the list of Tomcat and JSP-compatible Web containers and ides.
Better appearance
Creating consistent design and layout for Web pages is one of the easiest ways to ensure a professional look. You may have seen enough websites to know that most of the pages in a single site share a uniform page header, end of the page, and a certain type of navigation bar. On well-designed sites, these elements present the same layout, content, and functionality on each page, while the main panel (usually called the content pane) changes with each view.
Previously, this layout was almost entirely implemented by the framework and framework set. Each segment of static content is placed in a frame, and the main content of the page is placed in the intermediate frame. The trouble with frameworks is that different browsers often display them in different ways to make them look different. Using a framework to link external sites from an internal page is more difficult than you think. Originally, users were allowed to view external content without leaving the site, but the results were often inconsistent. What the user sees is that the entire site is congested into a much smaller frame. Worse, your site will eventually be nested in another site frame. This chaos drives Web designers to find a better solution. Server-side include (SSI) is one type.