Results 1 to 8 of 8
Thread: java.net.URL in applet
- 03-21-2012, 10:39 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 13
- Rep Power
- 0
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.
- 03-22-2012, 01:39 AM #2
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.
- 03-22-2012, 06:17 PM #3
Member
- Join Date
- Mar 2012
- Posts
- 13
- Rep Power
- 0
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.
- 03-22-2012, 06:19 PM #4
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.
- 03-22-2012, 06:54 PM #5
Member
- Join Date
- Mar 2012
- Posts
- 13
- Rep Power
- 0
Re: java.net.URL in applet
thanks, I'm experimenting with "grant". havnt got it to work yet. am I on the right track?
- 03-22-2012, 06:58 PM #6
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 fileIf you don't understand my response, don't ignore it, ask a question.
- 03-22-2012, 08:50 PM #7
Member
- Join Date
- Mar 2012
- Posts
- 13
- Rep Power
- 0
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 :)
- 03-22-2012, 08:56 PM #8
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.homeIf you don't understand my response, don't ignore it, ask a question.
Similar Threads
-
java applet is not reading if java console is not open?
By boidi in forum Java AppletsReplies: 8Last Post: 12-14-2011, 12:40 PM -
Java Applet starts then the applet field goes light blue
By oki in forum Java AppletsReplies: 30Last Post: 08-26-2011, 09:05 PM -
Java Applet to Applet communication
By jsman in forum Java AppletsReplies: 3Last Post: 04-05-2011, 02:23 PM -
applet class inside java.applet.* or java.awt.*
By Manish87 in forum Java AppletsReplies: 1Last Post: 09-27-2010, 02:15 PM -
What're the differences between JSP, Java Script, and Java Applet?
By meili100 in forum New To JavaReplies: 3Last Post: 07-23-2008, 08:07 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks