include directive
JSP include action
and JSTL import tag
The include directive provides static inclusion. It ads content of the resource specified by its file attribute, which could be HTML, JSP or any other resource at translation time.
Any change you make in the file to be included after JSP is translated will not be picked up by include directive.
Since JSP is translated only once but can be requested many times it's not a very useful option. It was originally intended to include static contents like HTML header and footer for a web page.
The main difference between include directive and include action is that JSP includes action provides dynamic inclusion.
The content of another JSP or HTML page is included at request time, which any change you make in the file to be included will be visible to another JSP when requested.
This is ideal if you are importing content from dynamic resources like another JSP page. The file to be included is specified by page attribute of jsp: include tag.
Third option to include the output of one JSP page into another is JSTL import tag. This works pretty much like include action but the main difference between import tag and includes action is that import tag can include resources from the outside world.
If you use include directive or include action you are only limited to include the output of resource from the same project or another web application residing in the same container.
It is the most powerful and flexible way to include the content of one JSP to another. The file to be included is specified by url attribute of import tag.
1) The main difference between include directive and include action is that the former is static include while later is dynamic include. Also former uses file attribute to specify the location of the resource to be include while later uses page attribute.
3) The key difference between include action and JSTL import tag is that former can only include local resources but later can also include the output of remote resources, JSP pages or HTML pages outside the web container. include action uses page attribute while import tag uses URL attribute.
That's all on the difference between include direction, include action and JSTL import tag in JSP.
0 comments:
Post a Comment