Results 1 to 4 of 4
  1. #1
    DenniGa is offline Member
    Join Date
    Feb 2009
    Posts
    6
    Rep Power
    0

    Default [SOLVED] Applet reading from file on server

    I created an applet, and I want to put it on my website and have it read from a file on the server.

    As a test, I've tried to make my applet access a file from my C:\ drive, but it says that I don't have permission.

    My first question is: Is it possible to have an applet on the website read from a file on the server?

    Second question: How do I do this?

    PS: I use Netbeans and BlueJ.

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Applets can generally only access resources on the server they are downloaded from. This can be done using java.net.URLConnection or java.net.Socket.

  3. #3
    DenniGa is offline Member
    Join Date
    Feb 2009
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by OrangeDog View Post
    Applets can generally only access resources on the server they are downloaded from. This can be done using java.net.URLConnection or java.net.Socket.
    Thanks for the tip.

    I have a question: How does the applet know if I am accessing a file from the server it is located in or a server such as docs.google.com?

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    The Java system and web browser on the client machine know from which domain the applet was downloaded. This has to match the domain used in connect() calls and similar.

Similar Threads

  1. reading URL using java through proxy server
    By asheesh in forum Networking
    Replies: 16
    Last Post: 04-25-2010, 02:15 PM
  2. Replies: 2
    Last Post: 10-05-2008, 06:13 PM
  3. Reading a file from Applet (BufferedReader)
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 06-22-2008, 10:51 PM
  4. Applet - reading text files packed into JAR file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:15 AM
  5. Reading/Writing files through Applet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-15-2007, 08:20 PM

Posting Permissions

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