Tuesday, July 28, 2009

How to make a Java applet that can start another Java prg. used for socket communication?

I want to design a Java applet that can start another Java program that will be used for socket based communication. I tried to make the communication with another applet but I’ve failed. So, I’ve got the idea of using a Java program for communication to be called from an applet. Is that possible. How? Any one can assist me?





Thanks in advance

How to make a Java applet that can start another Java prg. used for socket communication?
Have you tried RMI or Ajax? sorry Please put more details
Reply:You cannot do this without a signed/trusted applet. Applets are restricted to what ip they can communicate with - the one they origionated from.
Reply:It is a little difficult to tell, but it sounds like you were originally trying to figure out how to have one applet call another applet. If so, here is how:





Each applet to be called needs to be named, e.g.


%26lt;applet code=MyRegisterApplet name=register width=...%26gt;





Then, the caller needs to get a reference to the callee:


Applet applet = getAppletContext().getApplet("register")...


if (applet instanceof MyRegisterApplet){


MyRegisterApplet register = (MyRegisterApplet)applet;


//call the other applet's methods


Map map = register.getRegistry();


...


No comments:

Post a Comment