Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include directive and <jsp:include> attribute name problem

Tags:

java

jsp

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

like image 423
Dusk Avatar asked Dec 22 '22 09:12

Dusk


1 Answers

<% 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).

like image 145
skaffman Avatar answered Jan 11 '23 07:01

skaffman