-
- /** lets us put multi-level get/put/call keys all in the same method */
- private class Sub extends JS.Obj {
- JS key;
- Sub(JS key) { this.key = key; }
- public void put(JS key, JS val) throws JSExn {
- ServletScope.this.put(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key)), val); }
- public JS get(JS key) throws JSExn {
- return ServletScope.this.get(JSU.S(JSU.toString(this.key) + "." + JSU.toString(key))); }
- public JS call(JS method, JS[] args) throws JSExn {
- return ServletScope.this.call(JSU.S(JSU.toString(this.key) + "." + JSU.toString(method)), args);
- }
- }
- private Sub getSub(String key) { return new Sub(JSU.S(key)); }
-
- public JS call(JS method, JS[] args) throws JSExn {
- //#switch(JSU.toString(method))
- case "session.invalidate": request.getSession(true).invalidate(); return null;
- case "context.list":
- String path = JSU.toString(args[0]);
- if (path.indexOf("..") != -1) throw new JSExn("cannot use .. in paths");
- File f = new File(cx.getRealPath("/") + File.separatorChar + path);
- if (!f.isDirectory()) return null;
- String[] contents = f.list();
- JSArray ret = new JSArray(contents.length);
- for(int i=0; i<contents.length; i++) ret.put(JSU.N(ret.size()), JSU.S(contents[i]));
- return ret;
- //#end
- return null;
- }
- public JS get(JS key) throws JSExn {