Little background real quick.  Tomcat allows you to define an
application Context in the server.xml

Such that, if you wanted a webapp called MyApp, you would set up a
Context in your server.xml file with the path "/MyApp" and the docBase
attribute pointing to the location of your web app.  In my testing, you
could use relative paths WITHIN your Context.  Meaning

If you had a file
/MyApp/testdir1/getRelative.jsp

You could include these files:

/myApp/inc.jsp (using "../inc.jsp" OR "/inc.jsp" )
/myApp/testdir1/inc.jsp  (using "inc.jsp" or "/testdir1/inc.jsp")
/myApp/testdir2/inc.jsp   (using  "../testdir2/inc.jsp" or
"/testdir2/inc.jsp" )


What you couldn't do was leave your Context and get something else
(like):

/inc.jsp
/YourApp/inc.jsp


According to the Servlet 2.3 specification, I do not believe this is a
bug. (SRV9.5)

"A web application exists as a structured hierarchy of directories. The
root of this
hierarchy serves as the document root for files that are part of the
application."


That seems to say that everything within the "MyApp" webapp should see
the directory as "/"  and you cannot go below root.

This seems to be consistent with the JSP 1.2 Documentation for
<jsp:include /> and <%@ include %> tags
(JSP 2.10.3; JSP 4.4)  


-Andrew


-----Original Message-----
From: Paul landolt [mailto:[EMAIL PROTECTED]] 
Sent: Monday, July 08, 2002 1:39 PM
To: Tomcat Users List
Subject: Re: Tomcat 4.0.3 and relative path includes.


1) I'm not precisely clear on your use of the Context (I am a tad new at
this). I would assume from your question that the proper response is
this: I am tryig to leave my current Context and go to a 'parent'
Context, not nessesarily the base context.

My test structure works out to the following:

docroot/index.html
docroot/testdir/index.jsp
docroot/testdir/inc.jsp
docroot/testdir/test2/index.jsp
docroot/testdir/test2/inc.jsp

The "not found" error occures when I try to include
docroot/testdir/inc.jsp (which is in the parent directory) from the file
docroot/testdir/test2/index.jsp

2) I have tried setting the CrossContext attribute to true as well as
false, both having no affect

3) Although the option still exists to create a subdirectory off of the
base context, I am trying to port an existing web app from Weblogic onto
Tomcat. I would like to avoid moving files around if possible.


What about the use of the <jsp:directive.include /> phrase rather than
<@include>? Are there substantial differences?

Andrew Conrad wrote:

> So you are trying to leave your current Context and go into the base 
> context?
>
> Have you set your Context attribute "CrossContext" to true?
>
> Have you tried making a subdirectory in your current Context, place 
> this file with the relative include in it, and tried to request the 
> file from the base of the current context to see if that has any 
> problems?
>
> - Andrew
>
> -----Original Message-----
> From: Paul landolt [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 08, 2002 11:19 AM
> To: [EMAIL PROTECTED]
> Subject: Tomcat 4.0.3 and relative path includes.
>
> Hello All. I am a New poster, so I hope I'm following proper protocol.
>
> I am having trouble with relative path @includes in Tomcat 4.0.3.  An 
> include from the same directory is fine, as is an include from a 
> sub-directory, like so:
>
> <%@include file="inc.jsp"%>
> <%@include file="test2/inc.jsp"%>
>
> However, trying to include from a higher directory generates a JSP 
> compile error. The JSP code:
>
>     <%@include file="../inc.jsp"%>
>
> generates the following error message:
>
>     org.apache.jasper.compiler.CompileException: 
> /testdir/test2/index.jsp(5,0) File "../inc.jsp" not found
>
> (There's lots more to the dump, but I didn't think it was pertinent. 
> And yes, the file IS there)
>
> So, here are my questions:
>
> 1) Is this a known issue? Have other people encountered this?
> 2) Is this a bug or a Spec feature? If a bug is there a bug report 
> pending on this?
> 3) Is there a viable workaround for this?
> 4) Is there a mechanism in JSP to determine the current directory (and

> therefor build up an absolute path)?
>
> Thanks
>
>     ...Paul
>
> --
> To unsubscribe, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to