Arun Thomas wrote:

> Hans,
>
> Thanks for the correction.  Let me just make sure I understood your point
> completely.
>
> You write that when a <jsp:include> tag is used, the content that is
> included is the result of processing
> the included page.  If I had called that page directly with the request
> (given appropriate parameters) I would
> have seen exactly the same content as that which is included by the tag?  Is
> that correct?

Simplistically stated, this is correct.  A couple of possible reasons for
differences:

* In the <jsp:include> case, the visual result will be the included page,
surrounded
  by any text displayed from the calling page (yah, that's probably pretty obvious
:-).

* If it wants to, the called page can determine whether it is being called directly

  or included, and can therefore vary its output.  You would do this by checking
  for the existence of request attributes with particular reserved names -- see the

  Servlet API spec documentation on RequestDispatcher.include for more info.
  For example, you might not want to generate the <head> section, or the <body>
tag,
  if you were being included into an existing page (presumably already within the
body).

The way I think about this is that the included JSP is a "visual component" that
can create a portion of a resulting page dynamically, just like you can use
server-side includes to create a portion of the page statically.  The reason to
separate the component into a separate JSP is if you want to use it in more than
one place.

For example, you might be building a portal site that has a small chat application
component, and you want to include that chat application on lots of different
pages.  Using a separate JSP to create the visual appearance of the chat
application lets you maintain and enhance the chat app by modifying one file,
instead of one file for each place you used it -- the same basic reason that Java
developers abstract common behavior into subclasses.

>
> Thanks again,
> -AMT
>

Craig

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to