I'm newbie to JSP and on particular page of my webapp I'm trying to determine whether user is logged in. To do this, I'm checking for session existance. If session does not exist then I will redirect user to the login page.
I'm confused by the fact that the following code
<%
if (null == session)
out.println("session is null");
else
out.println("session is not null");
if (null == request.getSession(false))
out.println("request.getSession() is null");
else
out.println("request.getSession() is not null");
%>
under any circumstances produces the following output:
session is not null request.getSession() is not null
I don't understand why the session exists even when I didn't create it. How do I check whether user is logged in or not?
Thanks in advance.