aspose file tools*
The moose likes Servlets and the fly likes How to get HttpSessionListener to respond? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get HttpSessionListener to respond?" Watch "How to get HttpSessionListener to respond?" New topic
Author

How to get HttpSessionListener to respond?

Thomas Kennedy
Ranch Hand

Joined: Jan 20, 2008
Posts: 137
I ran through the example in K&B on using ServletContextListener, that works fine.

But then I tried to use a HttpSessionListener to respond to a user's invoking a servlet by putting an attribute into the session. This listener never gets called.

My listener:



The DD:



The servlet, which I expected would trigger the session listener:



I expected that line 03 above would trigger the session listener to create the attribute. But the output is "Your dog is null". So I am not quite understanding how sessions work.

Am I going about this wrong? Or is this something I should not try at all?

Costs matter. Justice lies in processes not outcomes. Crime is caused by criminals.
Kris Schneider
Ranch Hand

Joined: Feb 14, 2001
Posts: 71
Thomas Kennedy wrote:But the output is "Your dog is null".


Hm. Well, if you didn't get a NullPointerException by referencing d.toString()...what does the SessionDog.toString method look like?
Thomas Kennedy
Ranch Hand

Joined: Jan 20, 2008
Posts: 137
Right, that's it! I was populating the breed member but not the name member. Fixed!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get HttpSessionListener to respond?