This discussion is archived
1 Reply Latest reply: Jul 3, 2011 4:50 AM by 793415 RSS

Applet connecting to own host

872925 Newbie
Currently Being Moderated
I have an applet embedded in a web page which needs to connect to the host where it has been downloaded. The purpose is retrieving a field from a database, so it invokes a script in the host and it expects to have the data returned
It used to work fine, which is what I would expected from what I have read in every site about applet restrictions: applets are allowed to connect to the host where they have been downloaded
But since one day on, it started to fail. I get the following exception:

java.security.AccessControlException: access denied (java.net.SocketPermission 94.127.188.135:80 connect,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
.
.
.

By tracing the code, I have seen that the exception is yielded in the last call of the following thread:

objurl = new URL(url);
HttpURLConnection conn = (HttpURLConnection)objurl.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", contentLength);
OutputStream os = conn.getOutputStream();

If someone could give me any hint, it will be greatly appreciated
Thanks in advance

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points