"Decancq, Michiel" wrote:
> Hi all,
>
> This is the include page :
>
> <%!
> static String showInclude()
> {
> String vStringToShow = "This is a string to proove the inclusion !";
> return vStringToShow;
> };
> %>
>
> And this is the page where it is included :
>
> <html>
> <head>
> <jsp:include page="../includes/CheckForConsultants.jsp" flush="true" />
> </head>
> <body>
> ...
> <%
> try {
> String vShow = CheckForConsultants.showInclude();
> } catch (Exception ex) {
> out.println("Something went wrong with the include
> :<BR>" + ex.getMessage());
> }
> %>
> </body>
> </html>
>
There are two kinds of inclusion in JSP -- compile time and run time. Compile time
inclusion (<%@ include file="....." %>) works like an #include in C or C++, and
incorporates the text of the included file into the page you are compiling. That's
what you should be using for the case above to work.
The <jsp:include> element is used to include a *separate* JSP page (or servlet) at
runtime -- because it's separate, you cannot refer to variables in one from the
other. This is more like server-side-includes supported by most web servers.
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