Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LoginServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
- private static final UserServiceInterface userService=UserService
- .getInstance();
- protected void doPost(HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- String username = request.getParameter("user");
- String password = request.getParameter("password");
- User user = new User(username,password);
- try {
- if (userService.isValid(user)) {
- HttpSession session = request.getSession();
- session.setAttribute("user", username);
- session.setMaxInactiveInterval(30 * 60);
- Cookie userName = new Cookie("user", username);
- userName.setMaxAge(30 * 60);
- response.sendRedirect("customers.jsp");
- } else {
- }
- } catch (DaoException ex) {
- response.sendRedirect("error.jsp");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement