This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session variable

 
ford Darcy Jr
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am creating a logout application using servlets. I am using session variables for logging off. But, I am getting a null pointer exception while using sessions.
The code is:
HttpSession session = request.getSession(false);
if(session != null) {
session.invalidate(); // null pointer exception here
}
Do I also need to create any session variables in login page also ?

Please let me know, where I am going wrong.

Thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on the container, the user credentials may or may not be contained on the session, and there may not even be a session. It is possible that this is what you are seeing.

You should check the documentation for your particular server, for example WebSphere uses a separate cookie to maintain authentication, and this cookie is not related to the session. Assume that one implies the other creates application errors. You also need to use the SSOAuthenticator.logout() to logout.

Dave
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic