hi Moly :

are you sure you print out the output after </html> ?

rgds



On Fri, Nov 6, 2009 at 10:43 AM, Molly <jesouhait...@gmail.com> wrote:

>
> Hello,
>
> I am trying to figure out how to output my HTML code. When I run the
> program I want "Your IP Address Is: (IP here)" to appear at localhost:
> 3000. It appears when I execute the code in Eclipse but nothing shows
> up in my browser. Can someone help? Thanks!! :)
>
> MY CODE:
>
> import java.io.*;
> import java.net.*;
>
> public class EchoClient {
>        public static void main(String[] args) throws IOException {
>
>                try {
>                InetAddress addr = InetAddress.getLocalHost();
>            byte[] ipAddr = addr.getAddress();
>
>            // Convert to dot representation
>            String ipAddrStr = "";
>            for (int i=0; i<ipAddr.length; i++) {
>                if (i > 0) {
>                    ipAddrStr += ".";
>                }
>                ipAddrStr += ipAddr[i]&0xFF;
>
>            }
>
>            int port = 3000;
>            ServerSocket srv = new ServerSocket(port);
>
>            // Wait for connection from client.
>            Socket socket = srv.accept();
>                BufferedReader rd = new BufferedReader(new InputStreamReader
> (socket.getInputStream()));
>                BufferedWriter bw = new BufferedWriter(new
> OutputStreamWriter(socket.getOutputStream()));
>
>            // write the HTML header
>            bw.write("<html><head><title>Socket</title><body>Your IP
> Address Is: </body></head></html>");
>            String str;
>            while ((str = rd.readLine()) != null) {
>                System.out.println(str);
>            }
>            rd.close();
>            System.out.println("Your IP Address is: " +ipAddrStr);
>        }
>        catch (IOException e) {
>
>        }
>    }
> }
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to