开发者

Two Applets in same page

I am trying to put two applets which share same code base but initialized with different paramaters in same web page.

process goes like this: applet.jar->create two applet tags, with different parameters, same jar in a page->deploy to server->access the pa开发者_如何转开发ge.

HTML looks like this:

<HTML> 
<HEAD> 
<TITLE>Java applet example - Passing applet parameters to Java applets</TITLE> 
</HEAD> 
<BODY> 
<APPLET CODE="Applet.class" WIDTH="400" HEIGHT="50">
    <PARAM NAME="PURPOSE"    VALUE="VIEW">
</APPLET> 

<APPLET CODE="Applet.class" WIDTH="400" HEIGHT="50">
    <PARAM NAME="PURPOSE"    VALUE="MODIFY">
</APPLET> 

</BODY> 
</HTML>

there is a panel in both applets which display messages...

Now, the problem is messages from one applet are displaying in other one!


This kind of behaviour (and worse) is often caused by mutable statics (sometimes dressed up as singletons). For many reasons, don't use mutable statics.


I think that if you add MAYSCRIPT to the APPLET tag, this will make your applet isolated with the other.

<APPLET CODE="Applet.class" WIDTH="400" HEIGHT="50" MAYSCRIPT>
    <PARAM NAME="PURPOSE"    VALUE="MODIFY">
</APPLET> 

Ok, it's not clean but if you can't change the codebase that's an easy way to fix this thing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜