Hello Chris, Justin,
The index.jsp file in the main directory contains the code <%@
include file="header.jsp" %> and it works great.
In the admin directory the index.jsp file contains this code <%@
include file="../header.jsp" %> obviously referencing to the parent
directory, where the header.jsp file sits. I don't want to have to
copy it to the child directory and maintain two copies of it.
But when I do this, I get an error every time. What am I doing
wrong? You can find the error below.
It's a good idea to start your include directives with a '/', making
your paths relative to the context path (the "webapp base URI", if you
will). As you can see, Tomcat is adding a leading '/' for you, which
makes the path into nonsense:
The JSP2.0 spec says that both context-relative paths and page relative
paths area allowed. Both are "as described in RFC 2396" meaning that
"../" is allowed too. For page relative paths, it is prepended by the
path of the JSP or tag that it is used in (relative to the context path)
so that the path eventually starts with a '/'.
#Section JSP1.2.1
While I agree it is better to use a context-relative path to make it
easier later to move the page around, I don't see why it wouldn't work
with "../header.jsp"..
There is another thread from the last 24 hours or so with someone asking
about changing context paths. This is the best way to do this:
<%@ include file="<%= request.getContextPath() %>/header.jsp" %>
Not sure if that compiles (I haven't touched JSP in years), but it's the
general idea.
No, this is a directive to the JSP translator so no Java code in it is
executed.
Regards,
Dies
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]