Search code examples
javasecurityioappletnext-generation-plugin

Read and write files in an applet


I was in the process of turning my jar that reads and writes files into an applet. It displays properly until I add in the read and write function. Then Firefox just shows a black box (no error popups).

I have done a lot of research and it seems in order to get it to work I need to have the applet signed and then it will ask the user for permission, however I also read that I can't make an applet write files and it must be server side.

So my question is can I make an applet read and write files without sever side scripting? and if so how do I get my applet signed (I read some tutorials but I'm kinda new to this).


Solution

  • An applet that is signed can read and write files on the local machine.

    There are two types of certificates that you can use, the first is a certificate you create with keytool, an app that comes with the JDK. The second option is to sign an applet with a certificate from a Certificate Authority like Verisign.

    The difference is that the self made certificate will show warning messages to the client specifying that the certificate isn't trusted. This is just a warning, but can scare users. The downside of a certificate from a real certificate authority is that it cost money.

    To generate a certificate use keytool -genkey

    then to do the signing, it depends how you build your applet.

    For instance if you use Ant, there is a signjar task that will sign the applet.