You can build a page with reusable components using one of two include mechanisms—the include directive or the <jsp:include> standard action.
The include directive does the include at translation time, only once. So the include directive is considered the appropriate mechanism for including content that isn’t likely to change after deployment.
The include directive essentially copies everything from within the included file and pastes it into the page with the include. The Container combines all the included files and compiles just one file for the generated servlet. At runtime, the page with the include runs exactly as though you had typed all the source into one file yourself.
The <jsp:include> standard action includes the response of the included page into the original page at runtime. So the include standard action is considered appropriate for including content that may be updated after deployment, while the include directive is not.
Either mechanism can include dynamic elements (JSP code with EL expressions, for example) as well as static HTML pages.
The include directive is the only position-sensitive directive; the included content is inserted into the page at the exact location of the directive.
The attributes for the include directive and the include standard action are inconsistently named— the directive uses “file” as the attribute while the standard action uses a “page” attribute.
In your reusable components, be sure to strip out the opening ...
With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.