Guest User

login

a guest
Jul 31st, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  2.             throws ServletException, IOException {
  3.         PrintWriter out = response.getWriter();
  4.         String user = request.getParameter("username");  
  5.         String pass = request.getParameter("password");
  6.         JSONObject json = new JSONObject();
  7.         try {
  8.              LoginMDao loginDao = new LoginMDao();
  9.              res = loginDao.checkData(user,pass);
  10.              status = res.split("###")[0];
  11.              message = res.split("###")[1];
  12.              log.info("result "+ res);
  13.              if(status.equals("success")) {
  14.                 HttpSession session = request.getSession();  
  15.                 session.setAttribute("user",user);
  16.                 session.setMaxInactiveInterval(30*60); //30min inactive time
  17.                 response.sendRedirect("Profile.html");;
  18.                
  19.              }
  20.              json.put("status", status);
  21.              json.put("message", message);
  22.              out.print(json.toString());
  23.              
  24.         } catch (Exception e) {
  25.             log.error("Exception  " ,e);            
  26.         }
  27.         finally {
  28.             out.close();
  29.         }
  30.        
  31.        
  32.     }
Add Comment
Please, Sign In to add comment