Include-Decl

Statically includes a declaration section from an external file. The external file should not contain the [! .. !] delimiters used to mark declarations within the page; instead the external file should just simple define methods/variables.

External declaration includes are useful when the same methods or variables need to be used by more than one page. These common methods can be abstracted out to an external file and then included by as many pages as needed.

If the file to be included is later modified (but the page itself is unchanged and hence not recompiled), the updated included file will not be seen in the page. The page should be updated or touch'ed to force it to recompile and hence load the included file again.

If the included file name is absolute (begins with a '/'), then it is relative to the servlet webapp, otherwiser it is relative to the current page.

Syntax

Include-Decl sections can appear anywhere in text sections.
[include-decl filename]
Quotes around the filename are optional.

Tag-Escape

To prevent the tag from being recognized, this tag can be escaped by prefixing the start tag with a backslash: \[include-decl

Example

An simple example of including an external file declaration.

It makes no difference where the include is located textually in the page, since all declarations are methods/variables in the generated page class (and the order of method declaration makes no difference in Java).

In this example, the external declaration file (common.methods) contains the following lines:

String greeting() {
	return "Hello world";
	}
<html> <body> [= greeting() ] [include-decl 'common.methods' ] </body> </html> Hello world