SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jul 2000
    Location
    Odense - Denmark
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi!

    How do I get an Java-Applet to read and write files on the local filesystem?
    My Book says it under the control of a Security Manager object which is controlled by the browser. But how do i make it "trust" my applet? (for example by questionening the user)

    Thanks in advance!

  2. #2
    SitePoint Member
    Join Date
    Oct 2000
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the user has to set internet security in internet options to allow this. i don't know how you would ask the user for permission and then change it yourself because of the same rights problem. maybe you could somehow detect what the user's security settings were and if they did not allow for file access, just have an error telling them to turn it on.
    go to www.kubmedia.com, a great web page design site, and sign up to be the first to find out when it launches!

  3. #3
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Most browsers will accept and trust your applet if it is digitally signed with a certificate from Verisign or Thawte. Both Microsoft and Netscape implement this in different ways which means two different certificates. You can find information about signing your applets on their respective developer sites.
    Wayne Luke
    ------------


  4. #4
    SitePoint Member
    Join Date
    Jul 2000
    Location
    Odense - Denmark
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your ansawers.

    To the first one:
    Changeing the securityoptions in the browser would be a bad idea right? So every applet could gain access to the filesystem, and I dont think many people would use my applet then.
    But anyways, how do you change it in Netscape 4.75? Cant seem to find the option

    To the second one:
    So in order to get it to work I have to BUY two certificates and then it only works on IE and Netscape? The great thing about java is that it works on allmost any platform, so this isnt a "nice" option either I think...
    The reason I ask is that I have sometimes seen a box in my browser asking if I would like to "trust" an application
    of some website. I thought this was with applets wanting to do things with my filesystem. But this isnt the case?

    My problem is that I want the user of my applet to be able to save his or hers work in the program so they can retrieve it later. But its a bit hard to do when you cant write files to their harddrives. Is there really a secutity-problem in letting the user select a file and give the applet access to this file?

    But anyways, when I try to write to the file the applet simply doesnt do anything. Why dont I get an IOException or some other error?

  5. #5
    SitePoint Member
    Join Date
    Jul 2000
    Location
    Odense - Denmark
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Stipid me!!!
    I ofcause get an SecurityException and not an IOException...

    Seems that you can grant applets access by manipulating some security-files, but it doesnt seem very userfriendly

  6. #6
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What about going through a CGI script and write/read those files to/from a web server? That what I did in my project!
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  7. #7
    SitePoint Zealot freejavahelp's Avatar
    Join Date
    Jul 2000
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    123finder,

    could you show me the code you used to execute a CGI script from an applet?

    thanks

    Jim
    http://www.freejavahelp.com
    Making Java REALLY Easy
    Tutorials, Forums, and Articles

  8. #8
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    URL url = new URL("URL");

    URLConnection connection = url.openConnection();
    connection.setDoInput(true);
    InputStreamReader inStream = new InputStreamReader(connection.getInputStream());
    BufferedReader in = null;
    in = new BufferedReader(inStream);
    ............ (read the data from in)
    in.close();

    Hope it helps!

    p/s: the URL will contain any variable you want to pass in the CGI script (and I believe the you need to encode it too)

    [Edited by 123finder.com on 10-19-2000 at 03:03 PM]
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


Bookmarks

Posting Permissions

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