this might get too wordy..
this project has a LOT to it, so i want to develop it in modules. each module is a sub-directory of the web app root.
the head and foot of the web app in its entirety will be the same, so i want to use the same files for that.
the navigation which resides in the head is going to change based on what module (sub directory) you are currently working in.
example:
webroot/index.jsp
webroot/inc/head.jsp
webroot/inc/foot.jsp
webroot/module1/index.jsp
webroot/module1/inc/navigation.jsp
below is an example of my: webroot/module1/index.jsp
PHP Code:
<jsp:include page="../inc/head.jsp">
<jsp:param name="title" value="Customer Management" />
<jsp:param name="pathtoroot" value="../" />
<jsp:param name="navfile" value="module1/inc/navigation.jsp" />
</jsp:include>
<jsp:include page="../inc/foot.jsp" />
Here is how i use those in /webroot/inc/head.jsp
PHP Code:
<%@page contentType="text/html" pageEncoding="UTF-8">
<%
// set root http path for image and misc links to work
String pathtoroot = "./";
if( request.getParameter("pathtoroot") != null ){
pathtoroot = request.getParameter("pathtoroot");
}
// set navigation file
String navfile = pathtoroot+"./inc/navigation.jsp";
if( request.getParameter("navfile") != null ){
navfile = "../"+request.getParameter("navfile");
}
%>
<!-- some html here -->
<jsp:include page="<%=navfile%>">
<!-- more html here -->
you can see that if the navfile is null, it just uses the path relative to the web root, .. however, when i'm accessing it from a lower directory, i send in the navfile variable, and have to back down out of the /webroot/inc/ directory (../) then add the path from the webroot to my module1/inc/navigation.jsp
summarized: it makes sense to me that my include path to module1/inc/navigation.jsp from module1/index.jsp should be relative to module1/index.jsp. instead, it is relative to my header include which is '/webroot/inc/head.jsp'
if that is how it works, then that is fine and dandy, i can accept that. what baffles me is that why when i call '/webroot/index.jsp' is the path relative to '/webroot/index.jsp' and not '/webroot/inc/head.jsp' ???
sorry for the lengthy reply, .. i figured out how to do it, .. i just don't know why it works that way. this makes me love php more and more.