Because that way of programming is cahotic.
You are doing too many things in one component. You are showing data and performing a key operation as a logout in one jsp.
Always try to keep your operations separated or your application can become really hard to mantain.
There's an architectural
pattern called MVC that helps you to avoid such situations. As you will go on programming you will feel the need of following it, it will help you to keep components simpler, easy to mantain and to update, not coupled one to the other.