Be aware of the size and number of static includes
Static includes are those includes that use the JSP include directive:
<%@ include file="value" %>
These includes are processed at the time the JSP is translated. The
entire text of the included file is inserted into the including JSP page.
The including JSP page size is increased when the
include directive is used.
Consider using dynamic includes instead of static includes
Dynamic includes are those includes that use the JSP include standard
action:
<jsp:include page="urlSpec" flush="true|false"/>
<jsp:include page="urlSpec" flush="true|false">
<jsp:param ... />
...
</jsp:include>
These includes are processed at runtime, so they do not affect the size of
the including JSP page:
- Dynamically included resources are processes during
execution.
- The response is included in the output of the JSP.
- This does not affect the size of the including page or
increase the risk of a Java compilation failure.
Dynamically included resources are invoked through the request handler of
the Web container, so it is slower than static includes.
Try to employ code-reuse techniques instead of copy-paste
If you have sections of JSP code that are repeated, consider moving the
code into reusable components such as JavaBeans, custom tags or dynamic
includes.
JavaServer Faces and dynamic includes
You can compose a single view from multiple JSP pages using the
<jsp:include> standard action or the JSTL
<c:import> action:
- All JSF component custom actions in included pages must be
nested inside the <f:subview> custom action.
- The <f:subview> custom action is part of
the JSF Core Tag Library, which is itself nested inside the
<f:view> custom action.
Enclose any template text or non-JSF custom actions present in a page
included with <jsp:include> or <c:import>
need to use the <f:verbatim> custom action. This insures
correct use of the RequestDispatcher.include() function. |