/** * Method execute * * @param mapping * @param form * @param request * @param response * @return ActionForward */ public ActionForward displaylocations( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { LoginForm loginForm = (LoginForm) form; Connection geconn = ConnectionFactory.getConnection(); String sql1 = "Select * from GE_LOCATION"; ArrayList ar1_id = new ArrayList(); ArrayList ar2_name = new ArrayList(); try { Statement st = geconn.createStatement(); ResultSet rs = st.executeQuery(sql1); while (rs.next()) { ar1_id.add(rs.getString("LOCATION_ID") + "-" + rs.getString("LOCATION_NM")); ar2_name.add(rs.getString("LOCATION_ID") + "-" + rs.getString("LOCATION_NM")); } loginForm.setAr1_id(ar1_id); loginForm.setAr2_name(ar2_name); } catch (SQLException e) { e.printStackTrace(); } return mapping.findForward("logout"); }
public ActionForward signIn( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { LoginForm loginForm = (LoginForm) form; // TODO Auto-generated method stub String location = loginForm.getLocation(); String locationid = location.substring(0, location.lastIndexOf("-")); String username = loginForm.getUsername(); String password = loginForm.getPassword(); Connection geconn = ConnectionFactory.getConnection(); HttpSession session = request.getSession(); try { Statement st = geconn.createStatement(); String sql1 = "Select * from GE_USER WHERE USER_NAME='" + username + "' " + "and PASSWORD='******' and LOCATION_ID=" + "'" + location.substring(0, location.lastIndexOf("-")) + "'"; ResultSet rs = st.executeQuery(sql1); if (rs.next()) { // Visitor Dashboard VisitorsDB vi = new VisitorsDB(); ArrayList a1 = vi.getVisitorsDateWise(location.substring(0, location.lastIndexOf("-"))); request.setAttribute("disvisitors", a1); session.setAttribute("LocationName", location); session.setAttribute("Locationid", location.substring(0, location.lastIndexOf("-"))); session.setAttribute("UserName", username); session.setAttribute("GateNo", loginForm.getGateno()); String id = session.getId(); System.out.println("Getting id is &&&&&&&&&&&&" + id); // For Material Inward MatinwardDB mi = new MatinwardDB(); ArrayList m1 = mi.getMatinwardDateWise(locationid); request.setAttribute("dismatinward", m1); // For Other Material Outward OthmatoutDB mo = new OthmatoutDB(); ArrayList m2 = mo.getOthmatoutDateWise(locationid); request.setAttribute("disothermatout", m2); // GRAPH CREATION AND DISPLAY PieChart chartCreator = new PieChart(); /** Create a PieDataSet* */ String realPath = getServlet().getServletContext().getRealPath("/graph"); /** Define a file location to save this chart */ String fileLocation = realPath + "/" + id + ".jpg"; // chartCreator.processgraphimage(fileLocation, // location.substring(0,location.lastIndexOf("-"))); return mapping.findForward("home"); } else { displaylocations(mapping, form, request, response); loginForm.setMessage("Location OR User name and Password does not match"); return mapping.findForward("logout"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return mapping.findForward("home"); }