6 import java.util.regex.*;
7 import javax.servlet.*;
8 import javax.servlet.http.*;
10 import org.ibex.util.*;
11 import org.ibex.util.Collections;
14 import org.prevayler.*;
17 public class ShellServlet extends HttpServlet {
18 private ServletContext cx = null;
19 private Prevayler prevayler;
22 // FIXME: destroy() counter with normal Servlet
23 public void init(ServletConfig sc) throws ServletException {
24 cx = sc.getServletContext();
25 prevayler = Prevalence.getPrevayler(cx);
26 prevalent = (JS)prevayler.prevalentSystem();
29 public void doPost(HttpServletRequest rq, HttpServletResponse rs) throws IOException {
31 try { r = (Shell.Request)new ObjectInputStream(rq.getInputStream()).readObject(); }
32 catch (ClassNotFoundException e) {
34 throw new IOException("exception receiving request, class not found");
37 JSScope scope = (JSScope)rq.getSession().getAttribute("scope");
39 System.out.println("creating new scope");
41 scope = new JSScope(null);
42 scope.put("prevalent", prevalent);
45 throw new IOException("unexpected JSExn");
47 rq.getSession().setAttribute("scope", scope);
50 try { ret = r.process(scope); } catch (JSExn e) { ret = e; }
51 new ObjectOutputStream(rs.getOutputStream()).writeObject(ret);