Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between include directive and jsp:include  RSS feed

 
devika cha
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone explain how include directive and jsp:include work ,
1)include directive will include page statically,ie if any change done to including page later will not reflect in including page .

2)jsp:include includes a page dynamically . ie whatever changes made in included page will reflect in including page .

has this concept changed according to new specifications .
has anybody a clear idea how it works?

thank you.
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is just a guess. I've read that standard SSI (server-side includes) may not get polled for updated content--that the webpage with the includes might get cached as an entire webpage (not sure if that's the same for all web containers or web servers or whatever). The jsp:include might make sure you're pulling the freshest changes by avoiding using that cached copy. However, this is just based on memories of reading articles related to this, so don't try to get a man to Mars based on what I'm saying! :roll:
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmm.

Whether you get to see modified content when you change an included file, static or dynamic, depends entirely on the application server, and even how that server is configured. It's got nothing to do with that.

Static and dynamic includes are totally different.
  • A static include is merged in with the JSP during the JSP compilation phase. The result is a single servlet which contains the entire content of the JSP and all of its static includes. This means that a static include must be a plain file with JSP content. It also means that a static include has no runtime performance overhead, since it all compiles down to a single Java source file and, ultimately, servlet. If you are familiar with C, it's like an #include.
  • A dynamic include is never merged like that. It is a separate web-app resource which gets to process the request. The content generated by this resource is included in the JSP response. In other words, a dynamically included JSP is compiled down to a separate servlet. This means that a dynamic include can be any web-app resource, such as a servlet, and does not have to correspond to an actual file on the disk. It also means that a dynamic include incurs some runtime overhead.
  • - Peter
    [ July 29, 2004: Message edited by: Peter den Haan ]
     
    Don't get me started about those stupid light bulbs.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!