Craig,

Thanks for the quick response. Your assumption was fairly accurate. It
originally returned a filename ending in ".html" since our design guy
creates the headers in DreamWeaver. I changed the extension to ".jsp", per
your suggestion, and everything worked as I had hoped for.

Thanks!

Peter

> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Craig R. McClanahan
> Sent: Monday, June 12, 2000 9:58 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Alternative to using variables in include directive
>
>
> Peter White wrote:
>
> > Hello,
> >
> > I'm building a site that includes a dynamic header file based on who the
> > visitor was referred by. I'm currently including the header as follows:
> >
> > <% if (referred_by != null && referred_by.equals("ClientA")) { %>
> >
> >     <%@ include file="ClientA/clienta-siteheader.html" %>
> >
> > <% } else if (referred_by != null && referred_by.equals("ClientB")) { %>
> >
> >     <%@ include file="ClientB/clientb-siteheader.html" %>
> >
> > <% } %>
> >
> > The site currently has over 100 JSPs and this will obviously become
> > cumbersome as more pages and referral sources get added. What
> I'd like to be
> > able to do is:
> >
> > <%@ include file="<%= ub.getSiteHeader(referred_by) %>" %>
> >
>
> The reason this does not work is that <%@ include %> is evaluated
> when the page is
> initially compiled, not when the request comes in.  The way to
> dynamically include
> different files is to use <jsp:include> with a request time
> expression for the page
> name.
>
> >
> > However, this returns a JSP Parse error. I realize I could use
> the following
> > bit of code instead but my include file contains java code that
> needs to be
> > translated and the jsp include tag just outputs the literal
> text contained
> > in the returned file:
> >
> > <jsp:include page="<%= ub.getSiteHeader(referred_by) %>" flush="true" />
> >
>
> What does getSiteHeader() actually return?  If it returns the
> context-relative URL
> of a JSP page (i.e. it ends in ".jsp"), then the JSP page will be
> executed and the
> output it creates will be returned.
>
> > Peter
> > [EMAIL PROTECTED]
>
> Craig McClanahan
>
> ==================================================================
> =========
> 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
>

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