Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why why HttpSessionBindingListener method didn't trigger?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My JDK version is 1.5,use tomcat5.5 as contianer.
When I start tomcat "contextInitialized(ServletContextEvent)" print.But when I add a value to session (request.getSession().getAttribute("userName","deng") ,the valuebound method didn't trigger.

I don't know why? please give me a help?

this is my web.xml configuration:




this is implements class :


[ August 29, 2007: Message edited by: deng shuangyi ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the API for SessionBindingListener:

Causes an object to be notified when it is bound to or unbound from a session. The object is notified by an HttpSessionBindingEvent object. This may be as a result of a servlet programmer explicitly unbinding an attribute from a session, due to a session being invalidated, or due to a session timing out.



http://java.sun.com/j2ee/1.4/docs/api/index.html

Notice the word "it" is in bold.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.request.getSession().setAttribute("userName","deng");
set,not get!

2.you don't need to add the HttpSessionBindingListener class to web.xml configuration.
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sylven
Please read carefully what Ben has posted, he has highlighted "it"
Which means, suppose you have a class MyAttribute implementing HttpSessionBindingListener and you do something like

session.setAttribute("MyAttriute",new MyAttribute());
Then the listener will be notified.

Yes you need not declate HttpSessionBindingListener in web.xml
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic