The <%@include%> directive is evaluated compile-time, when the JSP is converted into
Java. It must include an actual file on the filesystem. The file may contain anything, and certainly doesn't need to contain a complete JSP; it will be included verbatim in the page source before the page gets compiled (as in the #include directive of the C preprocessor, if you're familiar with that).
The <jsp:include/> action is evaluated request-time. That's why, as mentioned above, you have to use the include action if you dynamically want to change the stuff you include. The included resource doesn't have to be a file: you can include
any web-app resource, for instance a
servlet. If you include a JSP file, it must be a complete JSP. The HTML generated by the included JSP gets inserted into the HTML generated by the including JSP.
There is no performance penalty to using the include directive, but include actions are slower because they are evaluated as part of a request. Actions are often cleaner and much more versatile though, especially if you need any dynamic behaviour.
- Peter
[ April 03, 2003: Message edited by: Peter den Haan ]