String []userID = request.getParameterValues("deleteUser"); for(int i=0;i<userID.length;i++){ int userId = Integer.parseInt(request.getParameter("deleteUser")); User users = new User(); users.setUserID(userId); DAOManager mgr = new DAOManager(); mgr.deleteUsers(users); response.sendRedirect("reg.jsp");
public boolean deleteUsers(User user) { String sql = "DELETE FROM user WHERE userID=?"; try { Connection conn = getConnection(); PreparedStatement ps = conn.prepareStatement(sql); ps.setInt(1, user.getUserID()); ps.executeUpdate(); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
<% DAOManager mgr = new DAOManager(); User[] users = mgr.getAllUsers(); for(int i = 0; i < users.length; i++) { %> <tr> <td><input type="checkbox" name="deleteUser" value=<%=users[i].getUserID()%>></td> <td><%=users[i].getUserID()%></td> <td><%=users[i].getUserName()%></td> </tr> <% } %>
int userId = Integer.parseInt(userID[i]);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)