You are not suppose to change the username in the session. You put it once when you log in. You don't set it every time you load a page.
Of course it is null every time you do this:
String username = request.getParameter("username");
session.setAttribute("username", request.getParameter("username"));
If you don't pass the "username" as parameter in the request the first call will return null and then you will set null in the attribute.
The first call is completely useless if you have already put the username in the session after login.
So once you login put the username in the session and that's it. You don't need anything else. All you need to do next is get it from the session whenever you need it.
And after logout set it to null