[opencms-dev] jsp - check if external file exists - pls help

Philip Kuegler mailinglists at pcom.at
Fri Jan 23 10:09:37 CET 2009


Hi,

the answer is as simple as follows:

If you access a network share (e.g. samba, windows, whatever cifs share 
you can think of) and the share is not public the server requests 
authorization. In this case the "file.exists()" command fails because 
the share is not accessible without such authorization. However mounting 
a network share as a local drive does help here. In such a case the path 
resolution carried out by windows includes an auto confirmation with the 
stored user credentials which makes the path accessible.

Now you have following options:
1.) Make sure the path is correctly mounted on the local host 
(independent of the OS) and use the local host path to access the share
2.) Make the cifs share public accessible (works always everywhere)
3.) Use the jcifs package and hardcode proper access credentials: 
http://jcifs.samba.org/
4.) Move back in time, type "java access network share" on 
www.google.com, follow the advice found under the _first_ hit and don't 
ask this question.
5.) Say thanks and apologize for not searching yourself.

br,
Philip


aruc97 at virgilio.it wrote:
> Hi all,
> i'm using opencms 7.0.4+apache+tomcat+modrewrite+multisite in a 
> linux environment;
> everythings works properly.
> i have to implement the 
> following task:
>
> check if a given file exists inside an external folder 
> of reachable windows server (over the same network of the opencms 
> server).
>
> in opencms,
> i have created the following code inside a .jsp 
> page:
>
> <%@ page import="java.util.*, org.opencms.jsp.*, java.io.*"
>      
> buffer="none"
>      session="false"
> %>
>
> <%
>   File myfile = new File
> ("\\\\ip_of_external_reachable_server\\folder\\filename_to_check.
> txt"); 
>         if (myfile.exists()){
>            out.println("file 
> exists");
>         }else{
>            out.println("file does not exist");
>         }
> %>
> ---------------------
> the above code always output: "file 
> does not exist"
> without any errors;
> even if the file is really present 
> onto the external server.
>
> is this problem due to the "opencms VFS 
> limitation", so that the resource
> is always checked inside the VFS and 
> can not be an external UNC ?
>
> can you help me finding the right code to 
> accomplish the above task ?
>
> thanks in advance,
> Stefano.
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>   




More information about the opencms-dev mailing list