but it's been one that's bothered me off and on for months. I've
been trying to write an applet to establish a remote connection and
retrieve data. Simple, right? And it's been done before, I'm sure.
But I can't get the darned thing to work on a Web server, local or
otherwise. Here's the relevant code, minus the comments. Please
excuse the temporary hardcoding of a URL.
public void RequestXML(String path, String query)
throws java.net.MalformedURLException, java.io.IOException
{
URL dURL=new URL("http://localhost/test/planetdata.php");
URLConnection conn=dURL.openConnection();
conn.setUseCaches(false);
BufferedReader in=new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
String xmldata="";
while ( (line=in.readLine())!=null )
xmldata+=line;
in.close();
root = new Xparse().parse(xmldata);
}
Naturally, the whole applet works perfectly in the debugger, but when
I try to embed it in a Web page, I always get via JavaScript:
"Error: uncaught exception: java.security.PrivilegedActionException:
java.security.PrivilegedActionException:
java.lang.reflect.InvocationTargetException"
when I try to invoke the RequestXML method. I believe this occurs at
the getInputStream() call. Sounds like the applet doesn't have
permission to access the file, but shouldn't it? Running from a
server where the file is in the same directory as the applet?
As I've said, I've struggled with this off and on for months, and am
getting fairly pissed off over it. And of course all the Java
documentation is about as clear as 47 feet of crude oil.
Any help?