tags:

views:

56

answers:

2

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 page.

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!

A: 

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.

Tom Hawtin - tackline
A: 

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.

RealHowTo