I did the following
getJspContext().setAttribute("authUser", user, PageContext.SESSION_SCOPE);`
In my LoginServlet and the following
User currentUser = (User) getJspContext().getAttribute("authUser", PageContext.APPLICATION_SCOPE);
In the other servlet. But currentUser = null
, Only when I changed APPLICATION_SCOPE
to SESSION_SCOPE
it started to work.
So, the question is, why application scope doesn't see the variable I set in session scope, because in my opinion when I create variable in session scope, it is automatically becomes visible in application scope?