Made the server context a more useful concept.
[jsvc.git] / src / dolda / jsvc / util / Restarts.java
index 7725f28..06ab682 100644 (file)
@@ -34,11 +34,10 @@ public class Restarts {
                public void respond(Request req) {
                    req.status(303);
                    URL url;
-                   String rel = req.ctx().rootpath() + "/" + Misc.stripslashes(path, true, false);
                    try {
-                       url = new URL(req.url(), rel);
+                       url = new URL(req.rooturl(), Misc.stripslashes(path, true, false));
                    } catch(MalformedURLException e) {
-                       throw(new RuntimeException("Bad relative URL: + " + rel, e));
+                       throw(new RuntimeException("Bad relative URL: + " + path, e));
                    }
                    req.outheaders().put("Location", url.toString());
                }
@@ -77,4 +76,11 @@ public class Restarts {
     public static RequestRestart stdresponse(int code) {
        return(stdresponse(code, "An error occurred", Misc.statustext(code)));
     }
+    
+    public static RequestRestart done() {
+       return(new RequestRestart() {
+               public void respond(Request req) {
+               }
+           });
+    }
 }