/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONObject reqJSON = StringUtil.fromReaderToJSON(request.getReader()); JSONObject result = dao.uploadImage(reqJSON); response.setContentType("text/json;charset=UTF-8"); response.getWriter().write(result.toString()); }
/** @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()); }
@Override public void init() throws ServletException { log.debug("Servlet initiating."); expiry = Integer.parseInt(this.getServletConfig().getInitParameter("expireDuration")); passLength = Integer.parseInt(this.getServletConfig().getInitParameter("passLength")); subject = this.getServletConfig().getInitParameter("emailSubject"); String htmlPath = this.getServletConfig().getInitParameter("htmlTemplate"); InputStream htmlStream = this.getServletContext().getResourceAsStream("/WEB-INF/" + htmlPath); htmlTemplate = StringUtil.fromInputStreamToString(htmlStream); sqlProperties = (Properties) this.getServletContext().getAttribute("sqlProperties"); dao = new AccountDAO(); dao.setSqlProperties(sqlProperties); dao.setExpiry(expiry); log.debug("Servlet initiated."); }