You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Julien BARRET <ju...@advantys.fr> on 2000/06/15 10:38:39 UTC

Virtual directories + getRealPath() = bug ?

Hi all,

I am experiencing strange behaviors from tomcat (and some other jsp engines) when dealing with virtual directories
I am using Tomcat web server (for development) and here are my contexts:

<Context path="/" docBase="D:/dev/Projects/mywebapp/root">
</Context>   

<Context path="/virt_dir" docBase="D:/dev/Projects/mywebapp/my_virtual_dir">
</Context>

I try to use the getRealPath method like this:

1) getRealPath("/virt_dir/a/file.txt") this *should* return D:/dev/Projects/mywebapp/my_virtual_dir/a/file.txt

2) getRealPath("/b/another.txt") this *should* return D:/dev/Projects/mywebapp/root/b/another.txt

3) getRealPath("/dummy/non_existent_file.txt") this *should* return null (dir and file do not exist)


Here is the behavior of tomcat 3.0:

it *always* returns PATH_TO_THE_ROOT_OF_THE_JSP_FILE/getReal_Path_parameter

so if my jsp file (the one calling getRealPath(PATH)) is located under the root of my site (e.g /jsp/file.jsp) then the result will be:
D:/dev/Projects/mywebapp/root/PATH
In tomcat 3.1 this behavior changes, and tomcat returns the right path to the file

if my jsp file is located under a virtual path (e.g /virt_dir/jsp/file.jsp) then the result will be:
D:/dev/Projects/mywebapp/my_virtual_dir/PATH
(There are no changes in tomcat 3.1)

note that in all cases (3.0 or 3.1à, the getRealPath("/dummy/non_existent_file.txt") returns a directory instead of null


I am looking for some information about the use of vitrual directories in web servers and jsp engines...

So if anybody can help

Julien



On the way to try all this with tomcat as a module of apache... :-)

====================
Julien BARRET

ADVANTYS
julien.barret@advantys.fr
====================