• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with inter-applet communication

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have inter-applet communication between two applets at my JSP page.
It work's OK, but when I put them into separate JAR archives they get loaded and started correctly at my JSP page, but they does't see each other (no inter-applet communication).
e.g., I got the following error:



Both applets contains updateOtherApplets method and it is very simillar.
For example, here is code excerpt from Applet2, so you can see how it is implemented:



And there is code excerpt from my JSP page:



Why there is no inter-applet communication between applets when I put them into JAR archives?
[ October 09, 2005: Message edited by: Velika Srbija ]
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do the applets communicate if they are referenced in a static HTML page?
IE Leave off the jsp until you get the correct HTML coding.
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my test case for this problem. The instanceof test and ClassCast fails but the getClass() shows the same named class?
To get the programs to work I overrode an existing method (getForeground() in the applet to demonstrate that the applets can communicate.

How do you get them to work via casting?
I put the "Master" class definition in the Bullet jar. The Bullet class needs the definition to be able to do the cast.



******* The HTML for testing the above applets *******************************
<HTML><HEAD><TITLE>Test inter applet commuication</TITLE></HEAD>
<BODY>
<applet name="Master" code=Testing.AppletCommMain archive=AppletCommMain.jar width=200 height=100>
</applet>

<applet name="Bullet1" code=Testing.AppletCommBullet archive=AppletCommBullet.jar width=50 height=50>
</applet>

<applet name="Bullet2" code=Testing.AppletCommBullet archive=AppletCommBullet.jar width=50 height=50>
</applet>
</BODY>
</HTML>

************ The batch file that creates the jar files: **********************
@REM Make jar files for testing Applet Communications
cd ..
jar -cf Testing\AppletCommMain.jar Testing\AppletCommMain.class
jar -cf Testing\AppletCommBullet.jar Testing\AppletCommBullet.class Testing\AppletCommMain.class
 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank YOU very much!
Now, it is working the right way. I put all applets, that are referenced from the same JSP page, into single JAR archive and now it works without problems.
Though, I have some if statements in my JSP page, so there are situations when I don't need all applets loaded at once, but it doesn't mind to have all of them always available.
Thanks once again!

Norm Radder, if you don't mind, take a look at one of my older questions: Problem with drawing styled (attributed) text
Do you have any idea?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic