There are two include mechanisms available to insert a file in a JSP page. They are
1. include directive <%@ include file="child.jsp" %>
2. include action <jsp:include page="child.jsp" flush="true" />
The include directive includes the content of the file during the translation phase where as include action includes the content of the file during execution/request processing phase.
For include directive, JSP Engine adds the content of the inserted page at translation phase, so it does not have an impact on performance.
For include action, JSP Engine adds the content of the inserted page at run time which imposes extra overhead.
so for example for the page which you want to include is contains mostly static data , that can't be changed from one request to another request , then its better to use the
include directive , because as i explained above , this page content will be included into the source jsp at the time of translation phase, and this phase will occur only one time in the life time of the jsp page, and there by it will increase the performance by decreasing the time to give response to the client request
syntax : < %@include file="myheader.jsp" %>
if ur page contains dynamic data which mostly changes from the request to request the better to use the include action as below
<jsp:include page="myResule.jsp" flush="true"/>
No comments:
Post a Comment