Using the Include Tags

The include directive and jsp:include tags provide the ability to include different kinds of content into your page. Both provide the ability to import static text, but differ in how they handle inclusion of dynamic content.

For starters, the include directive can include JSP commands into your page. The text of the included file is just read in and then compiled into the page.

By contrase, the jsp:include tag actually invokes the target (which can be any kind of servlet) at runtime and includes that content into the page.

Here is an example of including a text file: This text was included. Here is some non-ASCII stuff 日本語にほんご€äåæç

Here is the same file included using jsp:include: This text was included. Here is some non-ASCII stuff 日本語にほんご€äåæç

Note that the jsp:include tag read in the bytes using the platform encoding, so you see the UTF-8 as three bytes, followed by a bunch of screen garbage. Ick.

Here is a JSP file included using the directive: July 3, 2008 7:57:35 PM PDT日本語

Here is the same JSP file included using jsp:include: July 3, 2008 7:57:35 PM PDT日本語