Firstly,
you should not be using scriptlets.
Java code in a
JSP has been discredited for over 9 years now, and their use at this point is irresponsible.
Using the JSTL and EL, the scenario could be as follows:
Let's say that when the user logins in, you place a scoed varibale named user in the session.For logging out, you simple remove the variable. You can invalidate the session, but it's really not necessary.
On pages, you can easily check to see if the scoped variable is in the session with: