while(isRunning == true) {
if (SSocket != null) {
try {
Socket socket = SSocket.accept();
PrintStream PStream = new PrintStream(socket.getOutputStream());
BufferedReader BReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String info = null;
while ((info = BReader.readLine()) != null) {
System.out.println("now got " + info);
if (info.equals("")) {
break;
}
}
String content = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Main></Main>";
PStream.println("HTTP/1.0 200 OK");
PStream.println("Content-Type: text/xml");
PStream.println("Content-Length: " + content.length());
PStream.println("");
PStream.println(content);
PStream.close();
BReader.close();
socket.close();
Thread.sleep(10);
} catch (Exception e) {
}
}
}
This code makes the server display a xml, but when I go to another page (e.g. http://10.0.0.101:39878/otherpage.html
), the content is the same. How do I do to change the contents of each page and enter a 404 when it does not exist?