request.getRequestDispatcher("usersList.jsp").forward(request, response);
}
if ( request.getParameter("command").equals("addUser") ){
UserDAO dao = new UserDAO();
User u = new User();
u.setIdUser(dao.maxId());
u.setLogin(request.getParameter("login"));
u.setPassword(request.getParameter("password"));
u.setName(request.getParameter("name"));
u.setSurname(request.getParameter("surname"));
u.setEmail(request.getParameter("email"));
if ( u.getPassword().length() != 0 && u.getLogin().length() != 0 ) {
dao.addUser(u);
}
request.getRequestDispatcher("redirect.jsp").forward(request, response);
}
if ( request.getParameter("command").equals("deleteUser") ){
UserDAO dao = new UserDAO();
int i = Integer.parseInt( request.getParameter("delId") );
dao.deleteUser(i);
request.getRequestDispatcher("redirect.jsp").forward(request, response);
}
if( request.getParameter("command").equals("wyloguj") ) {
session = request.getSession();
session.invalidate();
request.logout();
response.sendRedirect("/LucasServletProject");
}
if( request.getParameter("command").equals("error") ){
request.getRequestDispatcher("index.jsp").forward(request, response);
}
if( request.getParameter("command").equals("editUser")){
if (request.getParameter("id") != null){
UserDAO dao = new UserDAO();
User u = new User();
u.setIdUser( Integer.parseInt(request.getParameter("id")) );
u.setLogin(request.getParameter("login"));
u.setPassword(request.getParameter("password"));
u.setName(request.getParameter("name"));
u.setSurname(request.getParameter("surname"));
u.setEmail(request.getParameter("email"));
dao.modifyUser(u);
request.getRequestDispatcher("redirect.jsp").forward(request, response);
}
}