/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String loginid = request.getParameter("loginid"); String pass1 = request.getParameter("pass"); // String password=request.getParameter("password"); /* Other details will follow * * * */ try { DbConnection db = new DbConnection(); Connection c = db.createConnection(); Statement s = c.createStatement(); /*Here we need to check if password and other things are correct or not * Then modelling has to be done and we have to set the session and application objects after this. * */ // s.execute("insert into mr (name) values ('"+name+"')"); Just to see if the db connection // is working or not String query = "select * from USERMASTER where LOGINID='" + loginid + "'"; ResultSet rs = s.executeQuery(query); if (!rs.next()) { response.sendRedirect("/login.jsp?message=User doesnt exist!"); return; } String pass = rs.getString("LOGINPASSWORD"); if (!pass.equals(pass1)) { // System.out.println("Not Equal!!"); response.sendRedirect("/login.jsp?message=User/password doesnt match !"); return; } HashSet set = (HashSet) getServletContext().getAttribute("OnlineList"); if (!set.add(loginid)) { // request.getSession().invalidate(); response.sendRedirect("/login.jsp?message=User allready logged in !"); } else { out.println("The name doesnt exist"); Mr user = new Mr(); user.setLoginId(loginid); user.setFirstName(rs.getString("FIRSTNAME")); user.setGroupName(rs.getString("GROUPNAME")); user.setLastName(rs.getString("LASTNAME")); user.setHqName(rs.getString("HQNAME")); user.setStateName(rs.getString("STATENAME")); user.setDob(rs.getDate("DOB")); user.setDoa(rs.getDate("DOA")); user.setMobileNumber(rs.getString("MOBILENUMBER")); request.getSession().setAttribute("UserInfo", user); if (rs.getString("GROUPNAME").equals("MR")) { out.println("send him to MR page"); response.sendRedirect( "/dcrmaintenance.jsp"); /// SUDIP HERE WE WILL DECIDE WHERE TO SEND HIM !!!!! } else { out.println( "send him to admin page"); /// SUDIP HERE WE WILL DECIDE WHERE TO SEND HIM !!!!! } out.println("Succesfull"); } } catch (Exception e) { e.printStackTrace(); } finally { out.close(); } }