There are two mechanisms for including content from another source in a JSP page: the include directive and the jsp:include element.
<%@ include file="filename" %>
For example, all the bookstore application pages include the file banner.jsp containing the banner content with the following directive:
<%@ include file="banner.jsp" %>
<%@ include file="initdestroy.jsp" %>
The include element is processed when a JSP page is executed. The include action allows you to include either a static or dynamic file in a JSP file. The results of including static and dynamic files are quite different. If the file is static, its content is inserted into the calling JSP file. If the file is dynamic, the request is sent to the included JSP page, the included page is executed, and then the result is included in the response from the calling JSP page. The syntax for the jsp:include element is:
<jsp:include page="includedPage" />
The date application introduced at the beginning of this chapter includes the page that generates the display of the localized date with the following element:
<jsp:include page="date.jsp"/>
From the J2EE Tutorial section on JavaServer Pages Technology by Stephanie Bodoff.
Maintained by John Loomis, last updated 31 March 2001