Question

What's the difference in using SSI include & JSP include?

e.g.

<!--#include virtual=&quot;page.jsp&quot; -->

and

<%@ include file="page.jsp" %>
Was it helpful?

Solution

SSI is executed by webserver engine and works in non-JSP files as well (e.g plain HTML files). It's executed on every request. JSP include directive is executed by container's JSP servlet and works in JSP files only. It's executed only once during JSP compile time and the result is inlined in the generated JSP class file which is reused multiple times. If you were using <jsp:include> instead of <%@include%>, then it would be executed on every request which allows for more dynamic includes. You can use for example <jsp:include page="${page}" />.

If you're already using JSP, I'd suggest to utilize the JSP include facilities instead as it allows for more optimisation and dynamics.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top