OMG, I'm so tired of trying to find this answer. I'll do my best to explain the issue. I have compiled, jarred and signed this browser applet:
import java.applet.Applet; import java.net.URL; import java.io.*; public class WebPipe extends Applet { public String getText(String url) throws java.net.MalformedURLException, java.io.IOException { URL resource = new URL(this.getDocumentBase( ), url); InputStream is = resource.openStream( ); BufferedReader in = new BufferedReader(new InputStreamReader(is)); StringBuilder text = new StringBuilder( ); String line; while((line = in.readLine( )) != null) { text.append(line); text.append("\n"); } in.close( ); return text.toString( ); } public void init() { // Call f() in HTML page } }
In the host page:<applet id="WebPipe" code="WebPipe.class" archive="WebPipe.jar" style="width: 1px; height: 1px; float: left;" mayscript></applet> <input type="button" onClick='alert(document.WebPipe.getText("http://myserver/test.txt"));'>
What I'm trying to accomplish is event driven data retrieval from a file on my server using the java applet as a "remote data connectivity driver" for JavaScript. I keep getting access denied. I'm not sure if its the browser or the server that is denying access but I can tell you the code works fine when called from the browser's body.onLoad event. I need to be able to post data and retrieve data with this "driver."
I suppose it really doesn't matter whether it is get or post, as long as I can pass parameters on the requested URL. Here is what the Javascript console reports after clicking the button:At this point exception handling is unimportant. the inability to get the content of the desired url is my problem.uncaught exception: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:80 connect,resolve)