How can I grant a permission from a Java Applet

I am building a project consisting in two applets
1- a TCP/IP server
2- a TCP/IP client

I want the applet 1 to listen on a port on TCP/IP, and the applet 2 to connect to the applet 1.
The project works when the two applets are run on local machine, or when they are applications (and not applets), but when I publish the applets, I get the following permission error :

java.security.AccessControlException:access denied (java.net.SocketPermissions xxx.xxx.xxx.xxx:yyyy accept, resolve)


where xxx.xxx.xxx.xxx is the ip address
  and yyyy is the port

I want to know how to ask the user for the permission to comunicate over network ( from the applet ).
The applet must work on a Linux/Windows workstation, in Iexplore/Netscape.

Thanx ...
danymagAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

girionisCommented:
 You will need to sign them in order to do it. Take a look here:

http://java.sun.com/products/plugin/1.2/docs/signed.html
http://www.securingjava.com/appdx-c/
0
danymagAuthor Commented:
Why do I need to sign them ...
In the same applet I use a print method, and it DOES manage to  ask the user for permission. Here goes the print method :


public void prin() {
     PrinterJob printJob = PrinterJob.getPrinterJob();
     printJob.setPrintable(this);
       
         try {
             printJob.print();
         }
         catch (Exception ex) {
             ex.printStackTrace();
         }
   
}


public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
           if (pi >= 1) {
               return Printable.NO_SUCH_PAGE;    }

Graphics2D g2=(Graphics2D) g;
g2.translate(pf.getImageableX(), pf.getImageableY());
this.paint(g2);this.repaint();
return Printable.PAGE_EXISTS;
    }



When launchd in application mode, it prints automaticly, but when launched as an applet it asks the user for permission (without having signed anything)

I want the same thing for the network communication ...
0
girionisCommented:
 You are trying to open a peer-to-peer connection, from one applet to the other, this is not allowed by default, since applets can only open connections to the server where the applets' class files reside.

  The second solution you can go for is to change the java.policy file but this will require manually changing it on every client machine.

  As for the printing stuff I guess the default permissions in your java.policy file allow the applet to print on a local printer.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.