• 1
  • 2
Home > Tips

Whatí»s the Difference between Static Include and Dynamic Include in JSP


Differences between Static Include and Dynamic Include in JSP

 

Last day I was taking an interview in my company. The interview was for WebSphere Commerce. So I thought of going directly to WCS questions. But that guy said that he was working on WCS long back and he forgot everything in WebSphere Commerce. Then I thought I will ask some JSP questions as he was mentioned JSP in each and every project in his resume.

I thought of starting with a usual JSP interview question. So I asked him what is the difference between static include and dynamic include in JSP. His answer was partially correct. So I though I will write a post on what are the differences between static include and dynamic include in JSP. So the difference between static include and dynamic include are:

1) The syntax for static include is <%@ include file=í▒filename.jspí▒ %> and the syntax for dynamic include is <jsp:include page=í▒filename.jspí▒ />
2) Static include is an inline inclusion. i.e., the contents of the file will be included at translation phase. Ití»s something like a copy and paste. In case of dynamic include the response of the file will be included to the original response at runtime. The file will be processed separately and only the response will become the part of the original filesí» response.
3) Static include cannot have a dynamic filename. This is because the servlet container needs the files for inclusion, at translation phase itself. But dynamic include can have a dynamic filename. Here the file is getting included at runtime.
4) Static include cannot accept a parameter (What this parameter will do even if are passing it?). But dynamic include can accept a parameter. (Here we have some one to do something on the parameter).
5) Static includes are faster than dynamic includes.

I believe these are the differences between static include and dynamic include. I think I have covered all. If I missed anyone, please let me know.

 

Choose a SliceMaker Product to Create a Website on Your Own-30 Day Freetrial
SliceMaker Standard V3.6 - Freeware
SliceMaker Standard V3.6 - Freeware
The anyone-can-master webpage making software. You can create exceptional webpage/website on your own even if you're unfamiliar with webpage making.
$0
$0
SliceMaker Platinum V3.6 - Freeware
SliceMaker Platinum V3.6 - Freeware
The bestselling webpage making software, helps you create exceptional webpage/website without writing complicated CSS and DIV codes.
$0
$0
SliceMaker Deluxe V3.6 - Freeware
SliceMaker Deluxe V3.6 - Freeware
The all-in-one webpage making software, helps you create webpage/website of any style. It's the idea tool to create webpage/website.
$0
$0