Thursday, 7 November 2013

static and dynamic inDifference between JSP include directive and JSP include actionclude

Difference between JSP include directive and JSP include action





SR
(Dynamic Include)
(Static Include)
1
The syntax for dynamic include is <jsp:include page="file.jsp”/>
The syntax for static include is <%@ include file=”file.jsp” %>
2
<jsp:include page=”relativeURL” /> is the JSP include action element.
The jsp:include action element is like a function call. At runtime, the included file will be ‘executed’ and the result content will be included with the soure JSP page. When the included JSP page is called, both the request and response objects are passed as parameters.
JSP include directive.
At JSP page translation time, the content of the file given in the include directive is ‘pasted’ as it is, in the place where the JSP include directive is used. Then the source JSP page is converted into a java servlet class. The included file can be a static resource or a JSP page. Generally JSP include directive is used to include header banners and footers.
3
dynamic includes is slower
Static includes are faster than dynamic includes
4
Dynamic include would throw a Page not found (HTTP Error 404), if the resource is not available at run time.
In static include if the resource is not available, the container would throw an internal server error (500).Once the page is compiled, even if the resource is not available, static include would work as expected. This is because the resource is already a part of the main file and it will not look for the file at run time.


5
dynamic include is more efficient for dynamic content
Static includes are more efficient for static content
6
dynamic include can accept a parameter.


<jsp:include page="/index.jsp">
 <jsp:param name="name" value="sos" />
</jsp:include>

Static include cannot accept a parameter
7
all thing here checked at Run time
The JSP compilation procedure is that, the source JSP page gets compiled only if that page has changed. If there is a change in the included JSP file, the source JSP file will not be compiled and therefore the modification will not get reflected in the output.

No comments:

Post a Comment

Very Impotent Links for Java and Portal development development

Jar Download for Spring  Maven Or Gradel Dependency for Spring