@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."); }
/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String to = request.getParameter("email"); String code = request.getParameter("code"); String timeStamp = request.getParameter("timeStamp"); JSONObject result = dao.confirmResetPass(to, code, timeStamp, passLength, subject, htmlTemplate); response.setContentType("text/json;charset=UTF-8"); response.getWriter().write(result.toString()); }