finished basic account add
[Bookkeeping.git] / src / com / interrupt / bookkeeping / http / EchoServlet.java
blob974a01d0a7fdc3eda63d7bb13a288bb696a52188
1 package com.interrupt.bookkeeping.http;
3 import java.io.IOException;
4 import java.io.OutputStream;
5 import java.io.PrintWriter;
7 import javax.servlet.ServletException;
8 import javax.servlet.http.HttpServlet;
9 import javax.servlet.http.HttpServletRequest;
10 import javax.servlet.http.HttpServletResponse;
11 import javax.servlet.http.HttpSession;
13 import org.apache.log4j.Logger;
15 import com.interrupt.bookkeeping.cc.ExpressionVisitor;
16 import com.interrupt.bookkeeping.cc.bkell.Bkell;
17 import com.interrupt.bookkeeping.cc.bkell.aauth.Aauthentication;
18 import com.interrupt.bookkeeping.system.BookkeepingSystemProperties;
20 public class EchoServlet extends HttpServlet {
22 private Logger logger = Logger.getLogger(EchoServlet.class);
24 public void init() throws ServletException {
26 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
27 this.process(req, resp);
29 public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
30 this.process(req, resp);
33 public void process(HttpServletRequest req, HttpServletResponse resp) throws ServletException {
36 com.interrupt.bookkeeping.ISystem system = (com.interrupt.bookkeeping.ISystem)req.getSession().getAttribute("system");
37 PrintWriter pwriter = null;
38 try {
40 if(system != null) {
41 System.out.println( "EchoServlet system: " + system.toXML(false) );
43 else {
44 System.out.println( "EchoServlet system: " + null );
48 pwriter = new PrintWriter(resp.getOutputStream());
49 if(system == null) {
51 pwriter.println("system NULL");
52 system = (com.interrupt.bookkeeping.ISystem)com.interrupt.bob.base.Bob.loadS(
53 Bkell.class.getResourceAsStream("/bookkeeping.system.xml"),
54 BookkeepingSystemProperties.instance().getProperty("bob.def") );
56 else {
57 pwriter.println(system.toXML(false));
59 req.getSession().setAttribute("system", system);
61 pwriter.close();
64 catch(IOException e) {
65 e.printStackTrace();