new xt shell based on JS transparency layer
[org.ibex.xt-crawshaw.git] / src / java / org / ibex / xt / shell / Servlet.java
index 44cc346..70b89d9 100644 (file)
@@ -22,33 +22,9 @@ public class Servlet extends HttpServlet {
     }
 
     public void doPost(HttpServletRequest rq, HttpServletResponse rs) throws IOException {
-        Request r;
-        try { r = (Request)new ObjectInputStream(rq.getInputStream()).readObject(); }
-        catch (ClassNotFoundException e) {
-            e.printStackTrace();
-            throw new IOException("exception receiving request, class not found");
-        }
-
-        JSScope scope = (JSScope)rq.getSession().getAttribute("scope");
-        if (scope == null) {
-            try {
-                scope = new JSScope(null) {
-                    { super.put("prevalent", prevalent); }
-
-                    public void put(String k, String v) throws JSExn {
-                        if (k != null && k.equals("prevalent")) throw new JSExn(
-                            "can not replace key prevalent");
-                        super.put(k, v);
-                    }
-                };
-            } catch (JSExn e) {
-                e.printStackTrace();
-                throw new IOException("unexpected JSExn");
-            }
-            rq.getSession().setAttribute("scope", scope);
-        }
-        Request.Response ret;
-        try { ret = r.process(scope); } catch (JSExn e) { ret = new Request.Response(e); }
-        new ObjectOutputStream(rs.getOutputStream()).writeObject(ret);
+        ObjectInputStream in = new ObjectInputStream(rq.getInputStream());
+        ObjectOutputStream out = new ObjectOutputStream(rs.getOutputStream());
+        JSRemote.receive(prevalent, in, out);
+        out.flush();
     }
 }