Hey guys, I figured it out. I actually just added a few lines to the
html code. Thanks for everyone's help! :) :)

On Nov 8, 6:36 am, jitesh dundas <jbdun...@gmail.com> wrote:
> Hi,
>
> It seems you are printing it to the log file of your web-server. For tomcat
> server, you will see the entry in the logs folder in the file (time at which
> you executed this program)..
>
> For web-based entry, try out.println(str) at all places..
>
> Again, this code is for a console based program. Try writing a servlet or
> jsp page. Execute this on the java console ( jdk\bin folder) and then try..
>
> To output to html, you write out.prinltn(str);
>
> You need the Java Complete Reference by Herbert Schildt and the Java
> Tutorial at java.sun.com....I think you need to get your basics right..
>
> Regards,
> Jitesh Dundas
>
> On Sat, Nov 7, 2009 at 12:13 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