How do you check if a session exists for the request in EL? I\'m trying something like:
... <
It's indeed never null
. The session is always present in JSP EL, unless you add
<%@page session="false" %>
to top of JSP. You could then check for the session as follows (EL 2.2 only!):
The session has been created before.
I'm not sure what's the concrete functional requirement is. If you'd like to check if the session is new or has already been created, use HttpSession#isNew() instead.
You've already visited this site before.
You've just started the session with this request!
(the brace notations for new
are mandatory because new
is a reserved literal in Java language)
Of if you're relying on a specific session attribute, such as the logged-in user which is been set as
session.setAttribute("user", user);
then you should rather be intercepting on that instead:
You're still logged in.
You're not logged in!