Reputation: 9579
My applet is supposed to take external parameters from html file which might be dynamically generated.
<param name="type1" value="value1">
<param name="type2" value="value2">
Those parameters has to be checked for validity in Applet.init()
String type1 = getParameter("type1");
String type2 = getParameter("type2");
if (type1 == null || type2 == null) ....
And they are wrong what should I do? Is it okay to call Applet.destroy()
manually?
As I know stop
and destroy
are supposed to be called by browser, not applet itself.
Upvotes: 0
Views: 771
Reputation: 168825
Applet.destroy()
should only be called by the JVM.
The best strategy here is to redirect to a page that shows the parameters and what is wrong with them. To do that, use something like:
URL brokenParams = new URL(this.getDocumentBase(),
"badparams.html?type1=" + type1 + "&type2=" + type2);
this.getAppletContext().showDocument(brokenParams);
This will have the effect that:
badparam.html
which shows the params and describes the problem. Then..Applet.destroy()
method will be called. (The 'right time' is typically 30-60 seconds later by my reckoning.)Upvotes: 1