Java – include directive and attribute name problem

javajsp

Why in JSP we write attribute name as file in include directive, but as page standard action?

Best Answer

<% include file="target.jsp" %> will inline the source of target.jsp into your page, and then the whole thing will then be evaluated as a single JSP. This is done at JSP compile time. This can be highly optimized by the container, and can have side-effects. For example, if you change the content of target.jsp, the container generally will not recompile the JSPs that included it.

<jsp:include page="target.jsp"/> will execute target.jsp as a seperate JSP, and then include the output of that execution into your page. This is done at JSP execution time. Note that this can refer to any path inside the container, not just a JSP (e.g. you can include the output of a servlet).