I created an applet that needs to execute the following code:
the code
public class Example extends JApplet { private ServerSocket ss ; private Socket socket; private boolean closed; @Override public void init(){ try { new Example().initialize(); } catch (IOException ex) { Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null,ex); } } public void closed(){ System.out.println("Inside close"); this.closed=true; } public void initialize() throws IOException{ ss =new ServerSocket(5002); while(!closed){ System.out.println("Waiting to accept request"); socket = ss.accept(); System.out.println("Request accepted"); } }}
HTML
A fragment of the HTML file for executing the applet:
<script type="text/javascript" > function closeCall(){ document.app.closed(); } </script> <body> <applet id="app" code="example.Example" archive="Example.jar" height="300" width="300"> </applet> <input type="button" value="go" onClick="closeCall()" />
Problem: when I click Go, my browser stops responding, and there is no error in javascript either. Is there a way to call the document.app.closed();
method document.app.closed();
?
source share