In the preceding chapters, we’ve worked with the different areas of the sample application as separate pages. Besides making it easier to explain the features one by one without overwhelming you with unrelated details, this approach also make sense for developing a real application, because you can work with smaller files that are easier to grasp and debug. At some point, though, you need to put all the pieces together. There are two ways to build up a JSF view from multiple JSP files: statically include all pieces into one file when the JSP page is transformed into a servlet and compiled, or dynamically include the files each time the main file is requested.
The JSP include
%>) supports the
static include option. It includes the contents of the specified
file, whether it’s a file with just plain markup
elements or a file with JSP elements. Because the include is
processed when the page is transformed into a servlet, the name of
the file to include must be entered as a static value. When a JSP
file is included this way, it shares the page scope (and all other
scopes) and all scripting variables with the including file. The
included file is rarely a syntactically complete JSP or HTML page; I
recommend that you use a different file extension to highlight this
fact. Any extension will do, but .jspf and
.htmlf are good choices (“f” stands for “fractional” or “fragment”). The container is not required to detect changes ...