Link to home
Start Free TrialLog in
Avatar of Neoteric
Neoteric

asked on

Applet/Servlet security

I have a servlet/applet rmi communication example which gives me this messages:

Problem establishing server socket: java.security.AccessControlException: access denied (java.net.SocketPermission localhost:1313 listen,resolve)

It seems I need to set a security manager somewhere, but I'm having trouble finding out where and how exactly what I need to do to grant the socket permission.
Avatar of girionis
girionis
Flag of Greece image

 You need to alter your policy file (java.policy) and give SocketPermission to localhost on port 1313 for listen and resolve. You have to do something like the following:

grant {
    permission java.net.SocketPermission "loclhost:1313", "listen,resolve";
};
Avatar of Neoteric
Neoteric

ASKER

Ok, thanks. Where should I put this file? Or where do I find it?
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great, I assume both applet and servlet need re-compiling under the new policy before uploading.
 Thank you :-)

  No, recompilation is not needed. However you will need to restart your server in order for the servlets to be able to use the new policy file. Note that Tomcat might have its own policy file so you might need to change that one as well :-)