in = new BufferedReader (new InputStreamReader(client.getInputStream()));
out = new DataOutputStream(client.getOutputStream());
ps = new PrintStream(out);
public void run() {
String line;
try {
while ((line = in.readLine()) != null && line.length()>0) {
System.out.println("got header line: " + line);
}
ps.println("HTTP/1.0 200 OK");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ps.println("Content-type: text/html\n\n");
ps.println("<HTML> <HEAD>hello</HEAD> </HTML>");
}
The program runs without errors and ps.println does not print anything to the browser. Any idea why?
Have you tried flushing the stream ? Without any other info I'm guessing that your
PrintStream
is storing up the characters but isn't actually outputting them (for efficiency's sake).See flush() for more info.