When I run the code below as an applet I get this message:
Hello java
there was a problem
access denied (java.net.Socke tPermission yahoo.com resolve)
But when I take the same code for reading the url as an application it
works.
What do I need to do???
............
import java.net.*;
import java.io.*;
import java.applet.App let;
import java.awt.Graphi cs;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("H ello world!", 50, 25);
System.out.prin tln("hello java");
try{
URL url = new URL("http://yahoo.com");
URLConnection connection = url.openConnect ion();
PrintWriter out = new PrintWriter(
connection.getO utputStream());
out.println("st ring=stringToRe verse");
out.close();
BufferedReader in = new BufferedReader(
new InputStreamRead er(
connection.getI nputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.prin tln(inputLine);
in.close();
}
catch ( Exception e)
{
System.out.prin tln("there was a problem");
System.out.prin tln(e.getMessag e());
}
}
}
...............
Hello java
there was a problem
access denied (java.net.Socke tPermission yahoo.com resolve)
But when I take the same code for reading the url as an application it
works.
What do I need to do???
............
import java.net.*;
import java.io.*;
import java.applet.App let;
import java.awt.Graphi cs;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("H ello world!", 50, 25);
System.out.prin tln("hello java");
try{
URL url = new URL("http://yahoo.com");
URLConnection connection = url.openConnect ion();
PrintWriter out = new PrintWriter(
connection.getO utputStream());
out.println("st ring=stringToRe verse");
out.close();
BufferedReader in = new BufferedReader(
new InputStreamRead er(
connection.getI nputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.prin tln(inputLine);
in.close();
}
catch ( Exception e)
{
System.out.prin tln("there was a problem");
System.out.prin tln(e.getMessag e());
}
}
}
...............
Comment