Reputation: 2716
I am trying to access to a session attribute from a Filter in my webapp running on Tomcat:
boolean socialLogin = (Boolean) session.getAttribute("socialLogin");
I'm getting a NullPointerException
, how can I handle the situation of if the attribute exists or not without having to catch a NPE?
The sessión is not null, I have checked it before.
Upvotes: 0
Views: 1227
Reputation: 12453
Have you tried to check for a null value?
if(session.getAttribute("socialLogin") != null) {
boolean socialLogin = (Boolean) session.getAttribute("socialLogin");
}
Upvotes: 2