Results 1 to 4 of 4
  1. #1
    gkirca is offline Member
    Join Date
    Dec 2009
    Posts
    3
    Rep Power
    0

    Thumbs down Filechecker in html via applet

    Hi all,

    nobody out there with an idea on this?
    I'm trying to implement a very little tool into my html code: a filechecker!
    It's not possible to use javascript for this, if you want to support other browsers than IE (ActiveX!).
    The html file I provide is a list of documents with an href set to the doc.
    The html file should be accessed via web but locally (e.g. CD or USB stick) as well (thus should work without XMLHttprequest).
    That's the intention!
    Now my code, how I tried to solve the problem:
    HTML code goes here >>>
    <html>
    <script type="text/javascript">
    function fileChecker (fileName) {
    var Test = document.applets["fileExist"].fileChecker(fileName);
    if (Test == "true") {
    document.write("exists");
    }
    else {
    document.write("does not exists");
    }
    }
    </script>
    <applet code="FileChecker.class" name="fileExist"></applet>
    <body>
    .some.other.useless.things.
    <p>Document titled 'Something' <a href="javascript:fileChecker("./directory/filename.zip")"</a>
    ...
    </body>
    </html>
    <<< HTML code ends here >>>

    Java code goes here >>>
    import java.io.File;
    import java.applet.Applet;

    public class FileChecker extends Applet {
    // serial ID has no effect
    // private static final long serialVersionUID = 1L;

    public boolean fileChecker(String fileName) {
    boolean retcode = false;
    File fileToCheck = new File(fileName);
    System.out.println("File to check: " + fileName);
    retcode = fileToCheck.exists();
    return retcode;
    }
    }
    <<< Java code ends here

    The result is ... not as expected. I checked the java console (level 5), no errors nor any exceptions! But I even get no result in my html page!

    Anybody has an idea?
    Any hint very appreciated and thanks in advance ...
    GK
    Last edited by gkirca; 12-22-2009 at 11:37 AM. Reason: Question

  2. #2
    gkirca is offline Member
    Join Date
    Dec 2009
    Posts
    3
    Rep Power
    0

    Question

    Hi community,
    nobody with an idea?
    Thanks in advance
    GK

  3. #3
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    368
    Rep Power
    5

    Default

    Hello!

    You want to write code and send it over net to someones PC
    that can play around with his file system ?

    You can't do that.
    It is security issue!

    It's up to the user to check it.

    You will never be able to have direct interaction with the user's filesystem
    using applets in this way (security issues can be changed on clients JVM but
    dont want to mess with that)

    So what CAN you do?

    You wait for user to choose file from its filesystem.

    When he does that, and BEFORE he submit form,
    your AJAX function listens to this event all time, and when it happens
    function send info about it to your server behind scenes.

    find any ajax basic example for this
    and i hope it will help you

    regards :)

  4. #4
    gkirca is offline Member
    Join Date
    Dec 2009
    Posts
    3
    Rep Power
    0

    Default

    Fon,

    Sorry for the late reply, I was a little busy in the last time.
    Thanks for your response. I know of the behaviour and the security restrictions, but I just want to find out, if it is possible to find a way to get around this.
    Meanwhile several colleagues told me the same. If I find a way (which I think will not happen), I'll update this thread.

    Thanks, merry christmas and a happy new year to all, who are reading this :-)

Similar Threads

  1. Two Form Applet in html
    By barusk in forum Java Applets
    Replies: 0
    Last Post: 03-16-2009, 06:36 PM
  2. Embedding Applet into HTML?
    By Unome in forum Java Applets
    Replies: 1
    Last Post: 02-21-2009, 04:40 AM
  3. Java Applet HTML
    By ownlol in forum Java Applets
    Replies: 4
    Last Post: 07-21-2008, 03:59 AM
  4. Chat Applet in HTML
    By Flynazn in forum Java Applets
    Replies: 3
    Last Post: 05-27-2008, 10:26 AM
  5. Create a Applet in the page HTML
    By Daniel in forum Java Applets
    Replies: 2
    Last Post: 07-04-2007, 08:52 AM

Tags for this Thread

Posting Permissions

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