}
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();
}
}