To further complicate this problem, I have tried more experimenting and am
becoming more frustrated.
The original situation remains below.
Now if I add a sub-directory to the admin subdirectoy, the directory structure
looks like this:
[main host directory (/host)]
index.jsp
header.jsp (ROOT VERSION, with a notation I can see in the html distinguishable
from others)
[admin sub directory (/host/admin)
index.jsp
header.jsp (ADMIN VERSION, with a notation)
[user sub directory (/host/admin/user)]
[justin sub directory (/host/admin/user/justin)]
index.jsp
As you can see, I have copied the header.jsp to the sub-directory admin and
have altered its contets so I can identify which header.jsp is being
used--namely that in the root directory or in the admin directory.
Then in the index.jsp file in the justin subdirectory, I use the code
<%@ include file="../../../header.jsp" %>
to reach the ROOT header.jsp to be included. But instead, the output in the
browser uses the file from the ADMIN directory.
So I figured I should just add ../ once more to move one more level up. so I
did.
<%@ include file="../../../../header.jsp" %>
But it used the ADMIN version again.
<%@ include file="../../../../../../../../header.jsp" %>
actually does too. What is the problem here?
And trying to go less instead of more,
<%@ include file="../../header.jsp" %>
this also works but uses the ADMIN version. Which is the expected behavior FOR
ONCE.
But then even less
<%@ include file="../header.jsp" %>
gives this error:
org.apache.jasper.JasperException: /sites/14/index.jsp(8,0) File
"/sites/14/../header.jsp" not found
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Can someone try to reproduce this error? I believe that Tomcat 5.5 and 6.0 do
not behave properly in this reguard. Unless I am making a mistake. If that is
the case, please guide me out of it.
Justin
When I enter the same
----- Original Message ----
From: Justin Jaynes <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, November 6, 2006 10:01:00 PM
Subject: Include Directive
Hello,
I am trying to eliminate unnecessary duplication of code by using include
directives. Currently my directory structure is like this:
[main app directory]
index.jsp
header.jsp
footer.jsp
[admin subdirectory]
index.jsp
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.
Justin
HTTP Status 500 - type Exception report
message
description The server encountered an internal error () that prevented it from
fulfilling this request.
exception
org.apache.jasper.JasperException: /index.jsp(4,0) File "/../header.jsp" not
found
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: /index.jsp(4,0) File "/../header.jsp" not
found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:339)
org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:372)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:484)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1556)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]