David Yee wrote:

> Guys -
>         The problem I'm having is as follows:
>
> 1) All of my jsp pages have many things in common. A header, A footer, a
> copyright message, etc. These things are static in nature and will not
> change from page to page.
>
> 2) I want to include all these items, without having to produce code
> clutter, by placing these common things in a base jsp page which will can be
> inherited by other jsp pages.
>
> What is the best way to do this?
>

JSP does not have "inheritance" the way an object-oriented language does, but it
supports two variations of an "include" facility, similar to the "server side
include" capability supported by most web servers.  The idea is that you separate
your common components into individual JSP or HTML files, and include them in the
resulting page.  For static text, you can use the variation that includes the text
at compile time of the JSP page, like this:

    <%@ include file="copyright.html" %>

or, if the common stuff has dynamically generated information (i.e. it is a JSP
itself), you would include it at execution time like this:

    <jsp:include page="/menu.jsp" flush="true" />

In either case, you only need to create the common components once, and can use
them as many times as you need to.

Besides this approach, you might also think about using a framed presentation.
Each frame is filled in with a separate HTTP request, and the common stuff like
copyright notices could be just left in its frame instead of having to be sent
with every single page.

>
> -David
>

Craig McClanahan

===========================================================================
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