File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes sessionDestroyed works, but not sessionCreated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "sessionDestroyed works, but not sessionCreated" Watch "sessionDestroyed works, but not sessionCreated" New topic
Author

sessionDestroyed works, but not sessionCreated

Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
Any idea why my stdout.log in Tomcat would be recording print statements from sessionDestroyed but not sessionCreated?




This has been frustrating me for a while. I thought it simply wasn't listening, but apparently it is since I do get statements beginning with "Removed session" in the log file!
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Originally posted by Karelicek Huey:

UserAcctBean user = (UserAcctBean) session.getAttribute("currentuser");
String loginID = user.getLoginID();


Just a wild guess, but maybe currentuser attribute is not set yet,because the session has just been created.
So you are getting a null pointer exception when you call user.getLoginID.
You could try putting a try-catch block for NullPointer around that call, and see if this is the reason.


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
Thank you so much!

So simple...I remember that thought crossing my mind when I was first typing that line, but I totally forgot that later on. Details, details...
:roll:


Two thumbs up for you, man! Next one's on me.
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

No worries mate. As they say, two pairs of eyes are always better than one when hunting for bugs.
I was wondering though, whether it is a part of the specification that if an exception is thrown in one of these methods, the container must catch it and just continue.

cheers
Sonny
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: sessionDestroyed works, but not sessionCreated