Advertisement
Guest User

Untitled

a guest
Aug 18th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public class LoginServlet extends HttpServlet {
  2.  
  3. private static final long serialVersionUID = 1L;
  4. private static final UserServiceInterface userService=UserService
  5. .getInstance();
  6. protected void doPost(HttpServletRequest request,
  7. HttpServletResponse response) throws ServletException, IOException {
  8. String username = request.getParameter("user");
  9. String password = request.getParameter("password");
  10. User user = new User(username,password);
  11. try {
  12. if (userService.isValid(user)) {
  13. HttpSession session = request.getSession();
  14. session.setAttribute("user", username);
  15. session.setMaxInactiveInterval(30 * 60);
  16. Cookie userName = new Cookie("user", username);
  17. userName.setMaxAge(30 * 60);
  18. response.sendRedirect("customers.jsp");
  19. } else {
  20. }
  21. } catch (DaoException ex) {
  22. response.sendRedirect("error.jsp");
  23. }
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement