Thanks.

-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 23, 2000 5:03 PM
To: [EMAIL PROTECTED]
Subject: Re: Dynamic Include Files?


"Steiner, Jeff" wrote:

> Is there a way to include dynamic include files.  I am using the following
> code and am getting an error.
>
>   <% String myFile = "./centers/" + my_state + ".html"; %>
>
>   <%@ include file=myFile %>
>
> When doing this the variable does not get parsed.  I would think that I
> could read the contents of the file the hard way using the File and
network
> packages, but I do not want to do that if there is a better way to do it.
>

There is a very simple reason that this does not work -- <%@ include %>
directives
are processed when the page is *compiled*, but scriptlets are processed when
a page
is *requested* (i.e. later on).

If you want to dynamically construct the filename to be included like your
example,
do this instead:

    <% String myFile = "./centers/" + my_state + ".html"; %>
    <jsp:include page="<%= myFile %>" flush="true"/>

This works because <jsp:include> is also processed when the page is
requested.

>
> TIA,
>
> Jeff Steiner
>

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