Các ứng dụng viết cho nền tảng J2EE sẽ chạy trên bất kỳ máy chủ tương thích J2EE. Các nền tảng J2EE cung cấp một số lợi ích cho các tổ chức phát triển các ứng dụng, bao gồm cả một mô hình phát triển đơn giản hóa, công nghiệp-sức mạnh khả năng mở rộng, hỗ trợ cho các hệ thống thông tin hiện có, | WEB-TIER APPLICATION FRAMEWORK DESIGN 111 For example Figure shows the layout of a single page created by a template. Across the top of the page is a banner on the left is a navigation menu a footer appears at the bottom and the body content occupies the remaining space. Figure A Template Composes Other Views into a Consistent Layout Using templates in an application design centralizes control of the overall layout of pages in the application easing maintenance. Changing the layout in the template file changes the page layout for the entire application. More importantly the individual subviews like the Navigation Menu in Figure are used by reference in the template instead of by copy-and-paste. Therefore changing a subview means changing a single source file instead of changing all the files in which that subview occurs. Template implementation is most easily explained by example. In the sample application a JSP page called a template file specifies the page layout. The template file is a standard JSP page that uses custom tags to include subviews into each area of the page. The template references the individual subviews by name. Code Example is an example from the sample application that produces the layout shown in Figure . This file called is a JSP page that produces HTML. The file specifies the page layout as standard HTML tags and 112 CHAPTER 4 THE WEB TIER includes the content of other JSP pages using the custom tag insert shown underlined in the code example. @ taglib uri WEB-INF tlds prefix template html head title template insert parameter title title head body bgcolor FFFFFF table width 100 border 0 cellpadding 5 cellspacing 0 tr td colspan 2 template insert parameter banner td tr tr td width 20 valign top template insert parameter sidebar td . and so on . -- Code Example The Template JSP Page for the Layout Shown in Figure The JSP page includes the page named by the insert tag s parameter attribute at