You can store the login in the HttpSession (setAttribute). It is best to not keep track of the password. Read it once, authenticate and then keep a record in the session that the user is logged in. One way is to store the login only when authenticated. Keeping passwords in memory invites someone to do a memory dump and get them. The IP address is already available via the HttpRequest so you don't need to store it during the current session.
i have also other jsp files where i have to verify that the user is still logged before doing any action. for example, the user has created some article when logged in and then he passes to the welcome page so i have to verify that he is still logged in in order to let him some other actions. And there some other pages which must respond to the same senario. So do i have to verify that he is still logged in every page or there's a more clean way to do this.
and if this is the best way how can you advice me to do it the best possibly way.