Forum Stats

  • 3,851,381 Users
  • 2,263,969 Discussions
  • 7,904,691 Comments

Discussions

about applet

843811
843811 Member Posts: 49,851 Green Ribbon
Hi all.
A little question: I know that an applet can't read and write
files on pc but an applet can read a file on a server?

I have this statements:

( fileNameParam = //WEBGNI/pc_Pignotti/psj.rtf )

JTextPane1.setContentType("text/rtf");
try {
java.net.URL url = new
java.net.URL("file",null,fileNameParam);
JTextPane1.setPage(url);
}
catch (Exception e) {
System.out.println("Exception reading URL: " +
e.getMessage());
}

In kawa it works but with netscape I have this message from java console
:
Exception reading URL: access denied (java.io.FilePermission
\\WEBGNI\pc_Pignotti\psj.rtf read)

If otherwise i change the statement so:
java.net.URL url = new java.net.URL(fileNameParam);

I have this message :
Exception reading Url : no protocol : //webgni/pc_pignotti/psj.rtf

Where is the proble?

Thanks


Comments

  • 843811
    843811 Member Posts: 49,851 Green Ribbon
    Hi,


    The applet cannot write or delete a file because of security reasons. For that you have to create a policy file with the help of policy tool command.

    For creating a policy file and running an applet with the help of policy file is given in a good way in this URL.

    http://web2.java.sun.com/docs/books/tutorial/security1.2/tour1/index.html

    I hope this will help you.

    Thanks
    Bakrudeen
  • 843811
    843811 Member Posts: 49,851 Green Ribbon
    Hello

    After creating a policy file I found the following information useful:

    http://www.esus.com/javaindex/j2se/jdk1.2/javaxswing/toplevelcontainers/japplet/jappletsec/signjappcontrol.html

    Hope this helps

    Stuart
This discussion has been closed.