PDA

Click to See Complete Forum and Search --> : Connect to another website using Java Applet


lordadel
Mar 30th, 2010, 02:43 AM
Hello all,

Would someone please tell me how can i connect to a website using Java Applet and read the output stream from that site.

Thanks in advance.

ComputerJy
Mar 30th, 2010, 06:16 AM
You can read the Java Socket tutorial (http://java.sun.com/docs/books/tutorial/networking/sockets/)

lordadel
Apr 3rd, 2010, 01:06 AM
Thanks for your reply..

I have tried this and it's giving me errors while compiling.


import java.awt.*;
import java.applet.*;
import java.io.*;
import java.net.*;


public class testapplet extends Applet
{

URL myURL = new URL("http://www.google.com");
URLConnection conn = myURL.openConnection();
conn.setDoOutput(true);
conn.setDoInput(false);

InputStream is = conn.getInputStream();


System.out.println(is);

}


All i want is just a very simple and basic applet to connect to a website and grab the text response.

Thanks in advance.

ComputerJy
Apr 3rd, 2010, 12:56 PM
If you knew anything about programming, you'd know you can't place your method calls from the class body.

You'll have to override the start method.