Web Programming
Todo Web Application (Sessions)
Tasks
-
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.)
-
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
-
Modify the servlets
TodoListServlet
and NewTodoServlet
so that they use the todos of the logged-in user stored in the session.
-
(Optional) Add the name of the logged-in user to the title of the server page
todoList.jsp
.
-
(Optional) Add a button to the sever page
todoList.jsp
that sends a logout request to the UserAdminServlet
which invalidates the session.
Solution