CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2000
    Posts
    24

    get server file system

    Hi, there,

    when I try to access a file on Server side from An Applet, I can use URL, for example, "http://1.1.1.1/some/some.gif", which has to be an exact file name. If I want to get the file system structure, for example, if I want to check how many files are in "http://1.1.1.1/some" directory, how can I do it?

    When I try to use File class, it always gave me security warnning.

    Help !!! Thanks in advance.

    Yours Nicole


  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: get server file system

    To see anything on the server requires that the server give it to you. For example when you use a URL or URLConnection, you are using the HTTP GET method to ask for the file. So if your server has a command that will return a list of files, use that. For example FTP has a command that will request the server to return a files list.

    Norm

  3. #3
    Join Date
    May 2000
    Posts
    24

    Re: get server file system

    Thanks, dear,

    I am still not clear about your comments. At present, I use IIS4.0 as web server.

    Would you please send me some sample code,or give me other reference article. Thanks again.

    yours Nicole


  4. #4
    Join Date
    May 2000
    Posts
    24

    Re: get server file system

    Hi, there,

    When I wrote the following code in an Applet,


    ..................
    URL url = new URL(getCodeBase()+"WorkInProgress/test1/");
    File file = new File(url.toString());
    File[] children = file.listFiles ();
    ..................




    And when I run it in IE5, it always gives me the following error message:
    ---------------------------------
    JAR cache enabled.

    Opening http://64.16.6.114/ebiz/ADemo/testFile/testFile.class with cookie "ebizIntranet=USERID=Mark+Holman".

    java.security.AccessControlException: access denied (java.io.FilePermission http:\64.16.6.114\ebiz\ADemo\WorkInProgress\test1 read)

    at java.security.AccessControlContext.checkPermission(Unknown Source)

    at java.security.AccessController.checkPermission(Unknown Source)

    at java.lang.SecurityManager.checkPermission(Unknown Source)

    at java.lang.SecurityManager.checkRead(Unknown Source)

    at java.io.File.list(Unknown Source)

    at java.io.File.listFiles(Unknown Source)

    at testFile.testFile.jbInit(testFile.java:32)

    at testFile.testFile.init(testFile.java:20)

    at sun.applet.AppletPanel.run(Unknown Source)

    at java.lang.Thread.run(Unknown Source)
    -----------------------------------

    But, if I call file.getParent() method, it works well in Browser, and shows the correct parent directory.

    Would you please give me some instruction.
    Thanks.

    yours Nicole


  5. #5
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: get server file system

    The File class does Not read data from a server. It's only for local files. I don't think the use of the URL class in your code is correct. Your program is only reading data from the local computer.
    To read anything from a server requires that the server be able to receive commands and respond to them. For example the FTP protocol has commands for the client to ask the server for a directory listing and many other file management commands such as deleting and renaming files. Each server can have different protocols that it responds to.

    Norm

  6. #6
    Join Date
    May 2000
    Posts
    24

    Re: get server file system

    Thanks, Norm,

    Would you please give me some sample to use Java access Server File System with FTP protocal? I don't know how to write this kind of code.

    Thanks again.
    yours Nicole


  7. #7
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: get server file system

    I'm sorry, I don't have a code sample using FTP. FTP is normally used manually from a DOS console. It's an old protocol that has been in use for a long time. The protocol is documented in a RFC, but I don't know the number. There has been another question on the forum about using FTP. It's not a simple 3 lines of code thing.

    And not all servers have an FTP server.

    Norm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured