JSP Include Directives

Introduction :
1.    <%@ include  file=”filename” %>  is the JSP include directive.
2.     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.
3.     Then the source JSP page is converted into a java servlet class. The included file can be a static resource or a JSP page.
4.     If several Jsp’s requires some common code it is recommended to separate that common code in a separate file where ever it is required we have to place one include call. 
Syntax:   <%@ include  file=”filename” %> 
Advantages:
1.    It promotes reusability.
2.    Enhancement will become very easy.
3.     It improves maintainability.
Disadvantage:
1.    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
Example:
first.jsp:

<h2>This is First JSP</h2>
<%@ include file="/second.jsp" %>

second.jsp

<h2> This is second JSP  </h2>

Output:


Thanks For Making This Possible! Kindly Bookmark and Share it.

Technorati Digg This Stumble Stumble Facebook Twitter

No comments:

Post a Comment