Dynamic Jsp Include

I have a bunch of pages that I need to include in a file that will be copied to various different parts of the site. The pages I am including all reside in the same folder. Rather than having to change each of the relational filepaths each time the file is copied, I am adding a variable that will hold the filepath and insert it into each of the includes. The result resembles this:

<% String jsp_directory="/web/jsp/"; %>

<jsp:include page ="<%= jsp_directory + "include-me.jsp"%>" flush="true" />

<jsp:include page ="<%= jsp_directory + "include-me-too.jsp"%>" flush="true" />

<jsp:include page ="<%= jsp_directory + "include-me-3.jsp"%>" flush="true" />

Why is this not working?

[1011 byte] By [DavidKerka] at [2007-11-26 17:58:14]
# 1

Your syntax looks correct per this:

http://java.sun.com/products/jsp/syntax/2.0/syntaxref2020.html#8828

I tried your code and it works also, that is the contents of pages located under /web/jsp/ *are* being included inside the JSP in question.

What other problems are you encountering with this?

Message was edited by:

appy77

appy77a at 2007-7-9 5:11:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
It may be that since presently the file I am working on is in the same directory, jsp_directory = ""; I'll try moving it outside the /web/jsp/ directory and see if that works. I am not having any problems other than that, because if I comment out those lines everything works as expected.
DavidKerka at 2007-7-9 5:11:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Nope, no good.
DavidKerka at 2007-7-9 5:11:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Basically, the problem that I am having is that the page is generating but it doesn't have any of the content that it is supposed to have. I just viewed the source of the (entirely blank) page that is generated, and I see this:

<jsp:include page ="/web/jsp/include-me.jsp" flush="true" />

<jsp:include page ="/web/jsp/include-me-too.jsp" flush="true" />

<jsp:include page ="/web/jsp/include-me-3.jsp" flush="true" />

I can't think of any reason that the jsp:include shouldn't execute, given that the rest of the call is all correct.

DavidKerka at 2007-7-9 5:11:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I just used a non-generated include, and it didn't work. I think that probably means that this is a server problem, not a problem with my code, so I'm going to go talk to the server guys. Thank you very much for your help.
DavidKerka at 2007-7-9 5:11:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
It worked fine on Tomcat 5.5 , are you sure those include files are located under the web folder directly under the root context / ?
appy77a at 2007-7-9 5:11:27 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...