Web Programming
Todo Web Application (Sessions)
The objective of this exercise is to implement a session that contains the currently logged-in user.
Tasks
-
Create the server page
login.jsp
with a form that allows a user to log in or to register with his username and password.
(Hint: Use the value attribute of the submit buttons to distinguish the two actions.)
-
Implement the servlet
UserAdminServlet
that provides a doPost
method that either logs in or registers a user, depending on the button pressed.
On success, a session with the logged-in user is created; on failure, an error message is displayed on the login page.
-
Remove the global todo list from the servlet
TodoListServlet
and use the todo list of the logged-in user stored in the session instead.
-
Modify the server page
todoList.jsp
such that the title contains the name of the logged-in user.
-
(Optional) Add a logout button to the sever page
todoList.jsp
and extend the servlet UserAdminServlet
such that the session is invalidated if the button is pressed.
Solution