Web Programming

Todo Web Application (Sessions)

Tasks

  1. Create the server page login.jsp which contains a form that allows a user to log in or to register. (Hint: Use the value attribute of the submit buttons to distinguish the two actions.)
  2. Implement the servlet UserAdminServlet that uses the user service to provide the following methods:
    • doGet checks whether a user is logged in and forwards the request to their todo list if so, otherwise to the login form
    • doPost logs in or registers a user: on success, a session with the username is created and the todo list is displayed; on failure, an error message is displayed on the login page
  3. Modify the servlets TodoListServlet and NewTodoServlet so that they use the todos of the logged-in user stored in the session.
  4. (Optional) Add the name of the logged-in user to the title of the server page todoList.jsp.
  5. (Optional) Add a button to the sever page todoList.jsp that sends a logout request to the UserAdminServlet which invalidates the session.


Solution