1 package dolda.jsvc.util;
6 public class StdResponse extends RequestRestart {
7 private final int code;
8 private final String title;
10 public StdResponse(int code, String title, String message) {
16 public StdResponse(int code, String message) {
17 this(code, "An error occurred", message);
20 public StdResponse(int code) {
21 this(code, Misc.statustext(code));
24 public void respond(Request req) {
26 req.outheaders().put("Content-Type", "text/html; charset=utf-8");
28 out = new PrintWriter(new OutputStreamWriter(req.output(), Misc.utf8));
29 out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
30 out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">");
31 out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\">");
32 out.println("<head><title>" + title + "</title></head>");
33 out.println("<body>");
34 out.println("<h1>" + title + "</h1>");
35 out.println(getMessage());
36 out.println("</body>");
37 out.println("</html>");