Results 1 to 8 of 8
  1. #1
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default java.net.URL in applet

    hi

    I'm behind a router so I have an internal IP as well as an external IP.
    I'm running an applet on an apache server that is doing an URL("http://"+host+"/config.xml");
    the strange thing is, if i set "host" to my internal ip, everything works fine, but when i try
    the external IP it's not working. the config.xml file doesn't even show up in my web server access log,
    so it's like it's not even trying to access it.
    when running the applet in eclipse though, it's able to get the url with any of the ip.
    I was suspecting the browser java, but so far i've tested linux-firefox, windows-firefox, IE8 with same results. anyone got any ideas?
    Last edited by laxtrappa; 03-21-2012 at 11:08 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,274
    Rep Power
    25

    Default Re: java.net.URL in applet

    Are there any error messages in the browser's java console?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: java.net.URL in applet

    didnt think about viewing that. it says a lot...
    starts with "java.security.AccessControlException: access denied (java.net.SocketPermission 213.21.66.155 resolve)"
    Last edited by laxtrappa; 03-22-2012 at 06:54 PM.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,274
    Rep Power
    25

    Default Re: java.net.URL in applet

    An applet needs permission to connect to any site other than the one it was loaded from.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: java.net.URL in applet

    thanks, I'm experimenting with "grant". havnt got it to work yet. am I on the right track?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,274
    Rep Power
    25

    Default Re: java.net.URL in applet

    What is "grant"? Where is it used?

    There are a couple of ways to give an applet permission:
    sign its jar file
    make an entry in the .java.policy file
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    laxtrappa is offline Member
    Join Date
    Mar 2012
    Posts
    13
    Rep Power
    0

    Default Re: java.net.URL in applet

    the "java.policy.applet" file created by eclipse contains:
    grant {
    permission java.security.AllPermission;
    };
    this ought to solve the problem(?) but it doesnt...

    however, for those with the same problem, i found a workaround solution.
    when you mentioned "An applet needs permission to connect to any site other than the one it was loaded from.", it suddendly truck me.
    the apache web server "ServerName" defaults to 127.0.0.1, when it can't determine the IP it it's running from. setting the "ServerName" to the external IP in the apache config file solves the problem!
    now, i think I have a dynamic IP, but thats a whole other problem :)

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,274
    Rep Power
    25

    Default Re: java.net.URL in applet

    If you copied and renamed that .policy file to .java.policy and put it the the user.home folder the jvm would use it.
    After you put the file there use the policytool program to see if it finds the file.

    System.out.println(System.getProperties().getPrope rty("user.home")); // show user.home
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 8
    Last Post: 12-14-2011, 12:40 PM
  2. Replies: 30
    Last Post: 08-26-2011, 09:05 PM
  3. Java Applet to Applet communication
    By jsman in forum Java Applets
    Replies: 3
    Last Post: 04-05-2011, 02:23 PM
  4. applet class inside java.applet.* or java.awt.*
    By Manish87 in forum Java Applets
    Replies: 1
    Last Post: 09-27-2010, 02:15 PM
  5. Replies: 3
    Last Post: 07-23-2008, 08:07 AM

Posting Permissions

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