Include

Includes the contents of another file. The file is included dynamically (at page run time) so if the file to be included is modified, the modifications are seen instantly.

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

If you want to send additional parameters to the included page, see more detail.

Syntax

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

The name of the included file can contain expressions and hence be generated dynamically. For example:

[[ int i = 3; ]]
[include 'foo[=i].html' ]
will include a file called foo3.html in the page.

Tag-Escape

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

Example

An simple example of a conditional include (for illustrative purposes only). <html> <body> [[ String include_file_name = req.getParameter("name") + ".header"; ]] [include '[=include_file_name]' ] </body> </html> this is the admin.header this is the user.header