Q:

Java responses to browser

This code should be able to respond to client browser. 
This is my code for listening to browser:
public class simpleServer extends Thread {
static ServerSocket serverSocket;
public static void main(String[] args) throws IOException {
    serverSocket = new ServerSocket(8000);
    Thread t = new simpleServer();
    t.start();
}

@Override
public void run() {
    while (true) {
        try (Socket socket = serverSocket.accept();
                DataInputStream in = new DataInputStream(socket.getInputStream());) {
            String received = in.readUTF();
            System.out.println("What received: " + received);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}
}

Running code result:
java.io. EOFException
at java.io. DataInputStream.readFully(DataInputStream.java:197)
at java.io. DataInputStream.readUTF(DataInputStream.java:609)
at java.io. DataInputStream.readUTF(DataInputStream.java:564)
at myp.simpleServer.run(simpleServer.java:23)

I try localhost:8000
But the unable to connect! 

A:

I tried this code and works as expected:
public class SimpleServer implements Runnable {
    static ServerSocket serverSocket;
    public static void main(String[] args) throws IOException {
        serverSocket = new ServerSocket(8000);
        Thread t = new Thread(new SimpleServer());
        t.start();
    }

    @Override
    public void run() {
        while (true) {
            try (Socket socket = serverSocket.accept();
                DataInputStream in = new DataInputStream(socket.getInputStream());
                //this is too much noise
                //you can directly wrap the result from socket.getInputStream()
                //into the BufferedReader
                BufferedReader br = new BufferedReader( new InputStreamReader(in) )) {

                System.out.println("request from browser client:");
                String line;
                //reads and prints every line from the request
                while ( (line = br.readLine()) ! = null) {
                    System.out.println(line);
                }
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    }
}

Now you just need to write an appropriate response for your client. 
More info:

A Simple Http Server with Java/Socket? 
simple HTTP server in Java using only Java SE API

