Adam Rossi wrote:

> I am trying to figure out the best way to include a header and footer on
> every page on a web site which includes both JSP's and static HTML files.
> There are a couple of options, the simplest of which is to use the JSP
> include directive <%@ include file="/header.jsp" %> or the SSI directive
> <!--#include file="footer.html" -->. My header file is a JSP that displays
> the currently logged-in user's name, current time, etc.
>
> My question is one of efficiency. I am using Apache to serve the HTML files,
> and Tomcat to serve the JSP files. If I convert every HTML file over to a
> JSP file just to use the JSP include directive, then I would be delegating
> every page to Tomcat, requiring each page to be parsed by the Tomcat engine.
> Would the most efficient route be to use the JSP include directive on every
> existing JSP page, and to use the SSI include on every HTML file? This way,
> Apache would not have to delegate the .SHTML files to Tomcat. This is my
> inclination, but I have read that Apache SSI's are very inefficient.
>

There is an efficiency difference that depends on which type of JSP include that
you do.

If you use the <%@ include file="/header.jsp" %> type of include, the inclusion is
done at COMPILE time (i.e. the first time the page is accessed).  The text is
copied into the main page, just like an #include directive in a C program causes
source from another file to be included in the compile.  The generated servlet is
coded just as if the included text had already been in the main page, so there is
no runtime overhead at all.

If you use <jsp:include/> on the other hand (or the Apache SSI style include), the
inclusion is done at REQUEST time by extra processing in the appropriate server.

So why would I ever use runtime inclusion?  If I wanted dynamically changing output
from the "included" file, that would be the better choice.  Compile-time inclusion
(<%@ include %>) is best when you are including static HTML text.

>
> Thanks for your help.
>
> - Adam
>

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to