Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

diff between include action and include directive

 
sumeet29
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tell me diff. between include action and include directive ie.
<%@ include file="" %> -------------directive
<jsp:include page="filename" /> -------action
please tell me in details with example
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are very different in principle but accomplish similar functions in practice.
The directive just includes the TEXT of the included file in the main file AND THEN compiles the resulting page as ONE page therefore creating ONE corresponding servlet.
With the action, the included file is a SEPARATE servlet which is executed at request time and its output "chained" to the including servlet.
 
Junilu Lacar
Bartender
Posts: 7466
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a link you might want to visit:
http://java.sun.com/j2ee/blueprints/web_tier/qanda/index.html#directive
This section of Sun's J2EE Blueprints answers common questions related to J2EE applications' Web tiers. This section also discusses the differences between the two JSP include mechanisms and offers suggestions for deciding which mechanism to use for a given situation.
taken from this JavaWorld article on JSP Best Practices: http://www.javaworld.com/javaworld/jw-11-2001/jw-1130-jsp.html?
Junilu
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tony Alicea:
They are very different in principle but accomplish similar functions in practice.
The directive just includes the TEXT of the included file in the main file AND THEN compiles the resulting page as ONE page therefore creating ONE corresponding servlet.
With the action, the included file is a SEPARATE servlet which is executed at request time and its output "chained" to the including servlet.

Right... another way to think of it is the directive version is a static include -- it is a partial JSP page that normally is not run on its own (maybe a header or footer that you use on all your pages.
The action version is a dynamic include it is a full JSP that is executed, and its output is included in the parent JSP.
------------------
- Jessica Bradley
HP Bluestone
[This message has been edited by Jessica Bradley (edited December 20, 2001).]
 
Junilu Lacar
Bartender
Posts: 7466
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note too that the action version (<jsp:include> ) can include a static resource. I'm not quite clear on how the server determines whether a resource is static and dynamic though. Files that have the JSP extensions are dynamic and other extensions such as HTML, JS, TXT will normally be static. But you can have index.html mapped to a dynamic resource as well.
Jessica or Tony, would either one of you care to explain this further?
Thanks,
Junilu
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sumeet29:
Welcome to JavaRanch!
I would like to direct you to our username policy at:
http://www.javaranch.com/ubb/Forum10/HTML/000180.html
Please re register and come back! Thank,
---
Sheriff Tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic