HTTP Authentication JAVA
<p>I need to know what is the problem in the following code</p>

<pre><code>public class NewClass {

public static void main(String[] args) {
    try {
        while (true) {
            ServerSocket ss = new ServerSocket(7777);
            Socket c = ss.accept();

            BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream()));
            DataOutputStream writer = new DataOutputStream(c.getOutputStream());
            String temp;

            // read browser Request
            while ((temp = reader.readLine()) != null) {
                System.out.println(temp);
            }

            // send basic authentication request
            String response = "WWW-Authenticate: Basic realm=\"test\"\n"; 
            respons += "HTTP/1.1 401 Authorization Required\n";
            writer.writeBytes(response );
            writer.flush();

            // receive browser response 
            while ((temp = reader.readLine()) != null) {
                System.out.println(temp);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
  }
}
</code></pre>

<p>when i request <a href="http://localhost:7777" rel="nofollow">http://localhost:7777</a> from browser, the authentication dialog does not appear</p>

<p>why ???? </p>

<p>also i'm tried to send this </p>

<pre><code>  String response = "HTTP/1.1 401 Authorization Required\n";
                   response += "WWW-Authenticate: Basic realm=\"test\"\n"; 
</code></pre>

<p>also i sent full server response and without benefits </p>
