public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String username = request.getParameter("username"); String password = request.getParameter("password"); Customer customer = null; if (username == null || username.length() <= 0 || password == null || password.length() <= 0) { log.warn("Empty username and/or password used for login"); return ViewUtil.createErrorView("error.empty.username.or.password"); } // login function is handled by the appropriate access mode handler customer = accessModeController.login(username, password); if (customer == null) { log.warn("Invalid login attempt with username = "******" and password = "******"error.invalid.username.or.password"); } UserSession userSession = new UserSession(customer); request.getSession().setAttribute("userSession", userSession); String forwardAction = request.getParameter("forwardAction"); if (forwardAction != null) { log.info("Forwarding response to original request url: " + forwardAction); response.sendRedirect(forwardAction); return null; } else { response.sendRedirect("overview.htm"); return null; } }
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String id = request.getParameter("id"); if (Util.isEmpty(id)) { log.error("Missing required transaction id"); return ViewUtil.createErrorView("error.missing.transaction.id"); } Transaction transaction = null; try { String accessMode = null; if (adminManager != null) { accessMode = adminManager.getParameter("accessmode"); } if (accessMode != null && !accessMode.equalsIgnoreCase("jdbc")) { transaction = accessModeController.doGetTransaction(Integer.parseInt(id)); } else { transaction = bankManager.getTransaction(Integer.parseInt(id)); log.info("Using regular JDBC connection"); } } catch (NumberFormatException e) { log.error("Invalid transaction id = " + id, e); return ViewUtil.createErrorView( "error.invalid.transaction.id", new Object[] {request.getParameter("id")}); } catch (DataAccessException e) { log.error("Invalid transaction id = " + id, e); return ViewUtil.createErrorView( "error.invalid.transaction.id", new Object[] {request.getParameter("id")}); } return new ModelAndView("transaction", "transaction", transaction); }