Websaver

Brad Fitzpatrick, <bradfitz@bradfitz.com>

What is Websaver?

Websaver is a set of Java classes that communicates with a Perl server on the webserver that allow the loading, saving, and listing of files on the server, in a protected file space. Using Websaver, it is possible to make applets that load and save their state. For instace, in a drawing program, users could save their pictures and other people could potentially load them, depending on the permissions they were saved with.

Installing the server

The first step to using Websaver is installing the server component. A shell script has been written to make this very easy. Log into cubist.cs.washington.edu and type what's shown in bold below: You should now have your very-own Websaver CGI script installed at:

Usage - in your applet

Download the Java Sources

Download this ZIP file of all the .java files you'll need for this, and unzip them into your applet's directory. If you're using J++, you may also need to add them to the current project.

Setup your Applet Parameters

Instead of hard-coding the path to the server in your applet, it's best to pass it as a parameter to the applet from your HTML file. Add in a parameter like this:

Changes to your applet class

Create your WebsaverConnection & Dialogs

In your applet's init() function, initialize your WebsaverConnection and dialog boxes like so:

Make your load & save boxes show the dialogs

In your actionPerformed(), add the bold code:

Do the loading and saving!

Now it's time to do the actual loading and saving... remember those methods websaverFileLoad and websaverFileSave you made earlier? It's time to fill those in. The parts in bold below you have to do. The rest you can (and should) copy verbatim. Note that you can do anything you want with the Input and Output streams, but object serialization is the fastest and easiest way to save things.

That's it!

That's it... you're done. Some things to note:

Need Help?

Post a message to the class mailing list at cse341@cs.washington.edu and if somebody doesn't help you by the time I check my mail, I'll help you out.