diff --git a/src/main/java/Repository.java b/src/main/java/Repository.java index 890dd4c..a5698c4 100644 --- a/src/main/java/Repository.java +++ b/src/main/java/Repository.java @@ -249,13 +249,14 @@ public static void updateTodoItem(TodoItem todoItem) { } - public static void deleteTodoItem(String id) { - String sql = "delete from TODO_ITEM where id = ?"; + public static void deleteTodoItem(String id, String user) { + String sql = "delete from TODO_ITEM where id = ? and user = ?"; Connection connection = getDBConnection(); try { PreparedStatement ps = connection.prepareStatement(sql); ps.setString(1, id); + ps.setString(2, user); ps.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); diff --git a/src/main/java/TodoServlet.java b/src/main/java/TodoServlet.java index bbd55ea..89c9582 100644 --- a/src/main/java/TodoServlet.java +++ b/src/main/java/TodoServlet.java @@ -20,6 +20,8 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t String todo = request.getParameter("todo"); String delete = request.getParameter("delete"); + // UTF8-problem i chrome... + // String html = "

TODO for bruker '" + user + "'

"; String html = "

TODO

"; String todoText = ""; @@ -27,7 +29,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t if (!isNullOrEmpty(id) && !isNullOrEmpty(delete)) { // Delete todo item - Repository.deleteTodoItem(id); + Repository.deleteTodoItem(id, user); } else if (!isNullOrEmpty(id) && isNullOrEmpty(todo)) { // View todo item