@Override public void init() throws ServletException { log.debug("Servlet initiating."); sqlProperties = (Properties) this.getServletContext().getAttribute("sqlProperties"); dao = new ThoughtDAO(); dao.setSqlProperties(sqlProperties); log.debug("Servlet initiated."); }
/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONObject reqJSON = StringUtil.fromReaderToJSON(request.getReader()); Thought t = (Thought) JSONObject.toBean(reqJSON, Thought.class, Thought.loadClassMap()); JSONObject result = dao.postThought(t); response.setContentType("text/json;charset=UTF-8"); response.getWriter().write(result.toString()); }