|
These days, users expect feature rich online applications and companies need flexible application design to deal with complex business rules. The day of having a single code file with all the application are gone. Modularization is the splitting up of complex code into separate modules of code. The following are the advantages of the modularization:-
- Coding and debugging both are very easy as compared to single file.
- The code is reused if required in the multiple pages.
- If any logic becomes obsolete then it can be replaced without disturbing other components in the application. The following tags are used to add the multiple JSP pages into one:-
a. <jsp:include>:- The <jsp:include> includes the given file on runtime. When container encounters this tag, it checks for the JSP file and compile that given JSP file. The output is then included in the page at runtime. As a result response time increases to some extent. It is always better to use <jsp:include> when the JSP page content are dynamically changes and the restarts of the servers are not done periodically. b. <%@include%>:- This tag includes the contents of the given file during the compilation of the JSP file. When the container encounter this tag it will generate the servlet and include all the contents of the included file to the servlet. Now if we change the included file then it would not reflect to its parent page until or unless it is reloaded to the container or the server gets a restart. So it is always better to use <%@include%> for the static type of the pages.
Example:-
The below is given the use of the <jsp:include> and also the <%@include%> tag.
<jsp:include page="coretaglib1.jsp"/><br> <%@include file="coretaglib2.jsp"%>
Output
The below output will be displayed.
 |