There are two implicit includes in JSP and both of these are configured in the deployment descriptor (web.xml) file.
1- One that is included in the beginning of every JSP matching the specified property group is called "include-prelude",
2- The other that is included at the end of ever JSP page matching the specified property group is called "include-coda".
The include-prelude element is an optional subelement of jsp-property-group. It has no subelements. Its value is a context-relative path that must correspond to an element in the Web Application. When the element is present, the given path will be automatically included (as in an include directive) at the beginning of the JSP page in the jsp-property-group. When there are more than one include-prelude element in a group, they are to be included in the order they appear. When more than one jsp-property-group applies to a JSP page, the corresponding includeprelude elements will be processed in the same order as they appear in the JSP configuration section of web.xml.
The include-coda element is an optional subelement of jsp-property-group. It has no subelements. Its value is a context-relative path that must correspond to an element in the Web Application. When the element is present, the given path will be automatically included (as in an include directive) at the end of the JSP page in the jsp-property-group. When there are more than one include-coda element in a group, they are to be included in the order they appear. When more than one jsp-property-group applies to a JSP page, the corresponding include-coda elements will be processed in the same order as they appear in the JSP configuration section of web.xml. Note that these semantics are in contrast to the way url-patterns are matched for other configuration elements.
Preludes and codas follow the same rules as statically included JSP segments. In particular, start tags and end tags must appear in the same file.
For example, the following web.xml fragment defines two groups. Together they indicate that everything in directory /two/ have /WEB-INF/jspf/prelude1.jspf and /WEB-INF/jspf/prelude2.jspf at the beginning and /WEB-INF/jspf/coda1.jspf and /WEB-INF/jspf/coda2.jspf at the end, in that order, while other .jsp files only have /WEB-INF/jspf/prelude1.jspf at the beginning and /WEB-INF/jspf/coda1.jspf at the end:
<jsp-property-group >
<url-pattern>*.jsp</url-pattern>
<include-prelude>/WEB-INF/jspf/prelude1.jspf</include-prelude>
<include-coda>/WEB-INF/jspf/coda1.jspf</include-coda>
</jsp-property-group>
<jsp-property-group>
<url-pattern>/two/*</url-pattern>
<include-prelude>/WEB-INF/jspf/prelude2.jspf</include-prelude>
<include-coda>/WEB-INF/jspf/coda2.jspf</include-coda>
</jsp-property-group>
No comments:
Post a Comment