You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lu Rui <mc...@gmail.com> on 2007/04/24 18:45:55 UTC

linux + tomcat, some path/link problem

hi, all,

     i'm writing a jsp front-end of a desktop search program in linux
using tomcat 5.5, here is my problem.

     say we need a result.jsp which can display the results from
lucene and show the related links, codes like below (hard-coding
for simple, as long as you can get my thougt is okay)

// for winxp
String filePath = new String("c:\\root\\test.html");


// for linux
String filePath = new String("/root/test.html");

<A href="<%= filePath %>"> testlink </A>

i've test this page both in winxp and linux. in windows,
right-click to check out the property of "testlink" you can see it
goes to " file:///c:/root:/test.html " and left-click then the browser
will open corresponding page, which is exactly what i've been
expecting.

but in linux here comes my trouble, i click "testlink" it
goes to "404 not found", then i check out its property and find it
leads to " http://localhost:8080/root/index.html ", it seems tomcat
took " /root " as a subdir of " /tomcat/webapps " and messed things up, totally
misunderstood my purpose.

as far as i know path is always a confusing problem of tomcat, but in
linux "/" stands for root of file system, so i'm clearly using an
abusolute path, why tomcat still made such mistake while it works well
in windows with " C:\\root\test.html" ?
and as mentioned above, this link, actually these links,
might go to anywhere in local file system, which makes the trouble
more complex, so i don't think setup Context or docBase or
relative-path could help much, i really need tomcat to be informed
that i'm using
abusolute path and i don't care it goes out of web project and that's
what i want.

plz help me out. thanks. and if what i said make you feel somehow offended,
it's not my bad feelings just my bad english..

while ( true ) {
 help me out;
}

regards.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: linux + tomcat, some path/link problem

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Lu Rui [mailto:mcrayes@gmail.com] 
> Subject: linux + tomcat, some path/link problem
> 
> // for winxp
> String filePath = new String("c:\\root\\test.html");
> // for linux
> String filePath = new String("/root/test.html");
> 
> <A href="<%= filePath %>"> testlink </A>

I have not verified the following, but this is what I think is
happening.

An href is a URI, not a file system path.  The URI handler in the
Windows JVM detects the "C:" prefix, and forces the protocol for the URI
to be "file:", since that's the only scenario in which "C:" makes any
sense.  No such hints are available on Linux, so the path is returned as
is, with no explicit protocol.  The HTML RFC requires that such paths be
treated as relative to the protocol and server used to present the page
in which the href occurs, so the _browser_ (not Tomcat) converts that to
"http://<host>/root/test.html".

To make the Linux version work like Windows, use an explicit protocol on
the path (e.g., "file:///root/test.html".

Note also that it's the browser handling the "file:" reference, so I
expect your scheme will only work when the client and server are on the
same machine.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: linux + tomcat, some path/link problem

Posted by LRS <mc...@gmail.com>.
David Smith <dn...@cornell.edu>
Martin Gainty <mg...@htomail.com>
Johnny Kewl <jo...@kewlstuff.co.za>
Caldarale, Charles R <Ch...@unisys.com>
Fargusson.Alan <Al...@ftb.ca.gov>

thank all you guys and those who are paying attention to this topic.

to Martin : thanks for reminding me of policy, i didn't know much of
that. but given with the same policy file, my web still goes well in
windows while it failed in linux, i don't think the problem is about
tomcat policy.

to Johnny: thanks for your fruitful information, although i did in
accord to what http://kb.mozillazine.org/Links_to_local_pages_don't_work
conducted, things still dont work out, and I got exhausted guessing
how many fold of slash there should be... oh,
internet/security/http/URI/browser/tomcat, everything goes wild, way
beyond I've expected. so i end up using LocalLink extention (a plugin
of mozilla firefox found in the page mentioned above) as a workaround,
anyway, my interest is about lucene + inotify, not firefox or tomcat.
and about ESE(from your description it seems like a program like
beagle), i'm intrigued about how it works around security problem, I'd
like to look into it some time.

thanks for all you guys' help and kindness again.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: linux + tomcat, some path/link problem

Posted by David Smith <dn...@cornell.edu>.
Johnny's right.  Just think of the fun and hijinks malicious web 
developers could bring to the table if they could reference any file 
(document or command) they could guess the path to.    Add some ajax and 
the fun get's even better. 

IMHO, it's a good thing this doesn't work.

--David

Johnny Kewl wrote:

>
> No... what I'm trying to tell you is that if your servlet makes a page 
> with file/// links... microsofts new security is going to stop it from 
> working.... nothing to do with Tomcat.
>
> Other browsers also do it
> If a page is delivered by Tomcat or any server with file:/// links you 
> going to have problems.
>
> Here are somethings to help u
> http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx
> http://support.microsoft.com/default.aspx?scid=kb;en-us;896204
> http://kb.mozillazine.org/Links_to_local_pages_don't_work
>
> And I just had lots of problems on IE with local file links...
>
> ITS A SECURITY THING...... NOT TOMCAT
>
> regards
> Johnny
>
> ----- Original Message ----- From: "LRS" <mc...@gmail.com>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Wednesday, April 25, 2007 3:45 AM
> Subject: Re: linux + tomcat, some path/link problem
>
>
>> thanks men, actually I've already tried to add " file:// " prefix
>> explicitly to filePath in A href link, and in mozilla I can see the
>> property of link appear to be " file:///root/test.html " , which is a
>> good sign, huh? but, woo, hate this but, no matter how hard i clicked,
>> the browsers made no reaction, it won't jump to test.html. the same
>> thing happened in opera, so I guess it maybe still have something to
>> with tomcat. I'm gonna work on this after work
>>
>>
>> Johnny Kewl <jo...@kewlstuff.co.za>
>> Caldarale, Charlie R <Ch...@unisys.com>
>> Fargusson.Alon <Al...@ftb.ca.gov>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: linux + tomcat, some path/link problem

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
No... what I'm trying to tell you is that if your servlet makes a page with 
file/// links... microsofts new security is going to stop it from 
working.... nothing to do with Tomcat.

Other browsers also do it
If a page is delivered by Tomcat or any server with file:/// links you going 
to have problems.

Here are somethings to help u
http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx
http://support.microsoft.com/default.aspx?scid=kb;en-us;896204
http://kb.mozillazine.org/Links_to_local_pages_don't_work

And I just had lots of problems on IE with local file links...

ITS A SECURITY THING...... NOT TOMCAT

regards
Johnny

----- Original Message ----- 
From: "LRS" <mc...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Wednesday, April 25, 2007 3:45 AM
Subject: Re: linux + tomcat, some path/link problem


> thanks men, actually I've already tried to add " file:// " prefix
> explicitly to filePath in A href link, and in mozilla I can see the
> property of link appear to be " file:///root/test.html " , which is a
> good sign, huh? but, woo, hate this but, no matter how hard i clicked,
> the browsers made no reaction, it won't jump to test.html. the same
> thing happened in opera, so I guess it maybe still have something to
> with tomcat. I'm gonna work on this after work
>
>
> Johnny Kewl <jo...@kewlstuff.co.za>
> Caldarale, Charlie R <Ch...@unisys.com>
> Fargusson.Alon <Al...@ftb.ca.gov>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: linux + tomcat, some path/link problem

Posted by Martin Gainty <mg...@hotmail.com>.
make sure you have granted the correct permissions in your catalina.policy
e.g.

grant codeBase "file:${java.home}/lib/-" {
        permission java.security.AllPermission;
};

M--

This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.

----- Original Message ----- 
From: "LRS" <mc...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, April 24, 2007 9:45 PM
Subject: Re: linux + tomcat, some path/link problem


> thanks men, actually I've already tried to add " file:// " prefix
> explicitly to filePath in A href link, and in mozilla I can see the
> property of link appear to be " file:///root/test.html " , which is a
> good sign, huh? but, woo, hate this but, no matter how hard i clicked,
> the browsers made no reaction, it won't jump to test.html. the same
> thing happened in opera, so I guess it maybe still have something to
> with tomcat. I'm gonna work on this after work
> 
> 
> Johnny Kewl <jo...@kewlstuff.co.za>
> Caldarale, Charlie R <Ch...@unisys.com>
> Fargusson.Alon <Al...@ftb.ca.gov>
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: linux + tomcat, some path/link problem

Posted by LRS <mc...@gmail.com>.
thanks men, actually I've already tried to add " file:// " prefix
explicitly to filePath in A href link, and in mozilla I can see the
property of link appear to be " file:///root/test.html " , which is a
good sign, huh? but, woo, hate this but, no matter how hard i clicked,
the browsers made no reaction, it won't jump to test.html. the same
thing happened in opera, so I guess it maybe still have something to
with tomcat. I'm gonna work on this after work


Johnny Kewl <jo...@kewlstuff.co.za>
Caldarale, Charlie R <Ch...@unisys.com>
Fargusson.Alon <Al...@ftb.ca.gov>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: linux + tomcat, some path/link problem

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
Ha ha.... boy of boy are you in for some pain... sorry cant help myself.

Well yes, you need to convert... because MS just didnt have the decency to 
ask the linux guys how to do it ;)

Heres a little code for you

                if(rawFileName == null) return "";
                if(rawFileName.length() == 0) return "";

                String s = rawFileName;
                s = s.replace('\\','/'); // make it unix compat
                s = s.trim();

                String firstChar = s.substring(0,1);
                if(firstChar.compareTo("/") != 0){
                    s = "/" + s;

something like that....
But this is why I'm talking to you.... have a look at file/// security 
restrictions on XP and later.
They going to get blocked.... so after all that pain... IE is going to drive 
you mad.... ha ha.

But I got some good news for you.... go to http://coolese.100free.com/
and download ESE... it does exactly that... its based on lucene and it 
allows you to search folders, and or dB's and then navigate the results in a 
browser.
Have a look at how it navigates.... it doesnt use file///   it turns the 
directories into a URL and navigates through Tomcat.... to get around 
security issues.
So yes I'm laughing coz I went through all this pain.... good luck.


----- Original Message ----- 
From: "Lu Rui" <mc...@gmail.com>
To: <us...@tomcat.apache.org>
Sent: Tuesday, April 24, 2007 6:45 PM
Subject: linux + tomcat, some path/link problem


> hi, all,
>
>     i'm writing a jsp front-end of a desktop search program in linux
> using tomcat 5.5, here is my problem.
>
>     say we need a result.jsp which can display the results from
> lucene and show the related links, codes like below (hard-coding
> for simple, as long as you can get my thougt is okay)
>
> // for winxp
> String filePath = new String("c:\\root\\test.html");
>
>
> // for linux
> String filePath = new String("/root/test.html");
>
> <A href="<%= filePath %>"> testlink </A>
>
> i've test this page both in winxp and linux. in windows,
> right-click to check out the property of "testlink" you can see it
> goes to " file:///c:/root:/test.html " and left-click then the browser
> will open corresponding page, which is exactly what i've been
> expecting.
>
> but in linux here comes my trouble, i click "testlink" it
> goes to "404 not found", then i check out its property and find it
> leads to " http://localhost:8080/root/index.html ", it seems tomcat
> took " /root " as a subdir of " /tomcat/webapps " and messed things up, 
> totally
> misunderstood my purpose.
>
> as far as i know path is always a confusing problem of tomcat, but in
> linux "/" stands for root of file system, so i'm clearly using an
> abusolute path, why tomcat still made such mistake while it works well
> in windows with " C:\\root\test.html" ?
> and as mentioned above, this link, actually these links,
> might go to anywhere in local file system, which makes the trouble
> more complex, so i don't think setup Context or docBase or
> relative-path could help much, i really need tomcat to be informed
> that i'm using
> abusolute path and i don't care it goes out of web project and that's
> what i want.
>
> plz help me out. thanks. and if what i said make you feel somehow 
> offended,
> it's not my bad feelings just my bad english..
>
> while ( true ) {
> help me out;
> }
>
> regards.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: linux + tomcat, some path/link problem

Posted by "Fargusson.Alan" <Al...@ftb.ca.gov>.
I may be completely miss-understanding, but I think this is a browser trick.  At least in IE7 when I have c: it assumes file:..., but when I don't have c: it assumes http:... .  You will probably need to code file:///root/test.html (I may have the wrong number of / after file:) to get this to work.

-----Original Message-----
From: Lu Rui [mailto:mcrayes@gmail.com]
Sent: Tuesday, April 24, 2007 9:46 AM
To: users@tomcat.apache.org
Subject: linux + tomcat, some path/link problem


hi, all,

     i'm writing a jsp front-end of a desktop search program in linux
using tomcat 5.5, here is my problem.

     say we need a result.jsp which can display the results from
lucene and show the related links, codes like below (hard-coding
for simple, as long as you can get my thougt is okay)

// for winxp
String filePath = new String("c:\\root\\test.html");


// for linux
String filePath = new String("/root/test.html");

<A href="<%= filePath %>"> testlink </A>

i've test this page both in winxp and linux. in windows,
right-click to check out the property of "testlink" you can see it
goes to " file:///c:/root:/test.html " and left-click then the browser
will open corresponding page, which is exactly what i've been
expecting.

but in linux here comes my trouble, i click "testlink" it
goes to "404 not found", then i check out its property and find it
leads to " http://localhost:8080/root/index.html ", it seems tomcat
took " /root " as a subdir of " /tomcat/webapps " and messed things up, totally
misunderstood my purpose.

as far as i know path is always a confusing problem of tomcat, but in
linux "/" stands for root of file system, so i'm clearly using an
abusolute path, why tomcat still made such mistake while it works well
in windows with " C:\\root\test.html" ?
and as mentioned above, this link, actually these links,
might go to anywhere in local file system, which makes the trouble
more complex, so i don't think setup Context or docBase or
relative-path could help much, i really need tomcat to be informed
that i'm using
abusolute path and i don't care it goes out of web project and that's
what i want.

plz help me out. thanks. and if what i said make you feel somehow offended,
it's not my bad feelings just my bad english..

while ( true ) {
 help me out;
}

regards.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org