April 11, 2020
Estimated Post Reading Time ~

When to use JSP include directive and jsp:include a tag?

The JSP include directive includes static content at compile-time and jsp:include includes static or dynamic content at run time.

1) Use the include directive
a. if the file includes static text
b. if the file is rarely changed (the JSP engine may not recompile the JSP if this type of included file is modified)
c. if you have a common code snippet that you can reuse across multiple pages (e.g. headers and footers)
d. Static includes are faster than dynamic includes

2) Use jsp:include
a. for content that changes at runtime
b. to select which content to render at runtime (because the page and src attributes can take runtime expressions)
c. for files that change often
d. dynamic include can accept a parameter


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.