Ok, finally made some progress. I got the applet up in the simplest
webapp (no wicket). It turns out I have to create a separate folder to
store all the related applet classes and dependent jar files in it. So
the directory ends up like this now:
META-INF/
|_ MANIFEST.MF
WEB-INF/
|_ classes/
| |_ mypacakge/
| |_ otherstuff.class
| |_ myapplet.class
|_ lib/
| |_ otherfiles.jar
| |_ jtreemap.jar
|_ web.xml
applets/
|_ mypackage/
| |_ myapplet.class
|_ jtreemap.jar
appletpage.html
And the applet tag is as follow:
<applet code="mypackage.myapplet.class" codebase="applets/"
archive="jtreemap.jar" height="550" width="800" />
This would allow the applet to run inside the webapp. HOWEVER, there
is still 1 more problem: the applet is not allowed to read/write the
local files. Because the way we make the applet communicate with
outside is to read in a data file, we use the "user.home" system
property in the code. Applets are not allowed to read that property.
After some googling, there seems to be 2 ways to solve this problem:
1. Signed the applet to give it a digital certificate. This requires
jaring the applet, and using the "keytool" utility that comes with the
Java distribution. Also we have to automate the process in Ant build
file since it's required for every deployment. Here is one tutorial I
found that might help:
http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html
2. Use the java.policy file to grant the permission. In the bin
folder, there's a file called java.policy.applet, which is generated
by eclipse. It grants all permission for the applet, which is why the
applet running inside eclipse is able to read/write local files. I
couldn't find too much info on how to use this file, though. After
all, it's sort of advanced and the signed applet is generally the more
preferable way to go.
Let's try to sign our applet.