• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please verify this....

 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,
This is more of a servlet spec question than a WLS question so I hope you don't mind me asking it here. I think I found a bug with weblogic's wappc ant task but I would like someone to confirm this.
I have a simple class which does nothing but implement the javax.servlet.http.HttpSessionBindingListener interface. I have referenced this class in the "listener" element in my web.xml file. When I compile using their ant task, I receive the following message:
"listener" element must implement at least one of the following interfaces, "javax.servlet.ServletContextListener" or "javax.servlet.ServletContextAttributeListener" or "javax.servlet.http.HttpSessionListener" or "javax.servlet.http.HttpSessionAttributeListener"
Am I right in saying that you can implement the javax.servlet.http.HttpSessionBindingListener interface here as well? I did not have a problem with this on tomcat or the sun one server.
Regards,
Joshua
 
Tieyi Guo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple class which does nothing but implement the javax.servlet.http.HttpSessionBindingListener interface. I have referenced this class in the "listener" element in my web.xml file.

I guess the problem is because you are not supposed to reference this class in your web.xml file. As I remember from the book, the container is using an introspective way to determine which object implemented the javax.servlet.http.HttpSessionBindingListener interface. It will automatically call the event-handling methods in that object. You do not need to add that class in your web.xml file.
I am not sure why Tomcat and Sun One did not give you error as WLS did. I guess WSL is just more regid in its error checking.
Hope this can be of some help.
Tieyi
 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought that you had to "register" all listeners in the <listener> element of the web.xml file.
Could you point me to some documentation which says otherwise?
Thanks,
Joshua
 
Shiva Mantri
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever an object is added/removed from session, the container introspects for interfaces implemented by that object. If it implements HttpSessionBindingListener, it calls appropriate method (valueBound/valueUnbound).
Also, for the listeners specified in web.xml, the container creates only one instance for each listener and events from all sessions are sent to the specific listener instance. Whereas, HTTPSessionBindingListener is specific to an Object.
Spec specifies that an object has to be notified, when the object is bound/unbound from/to session. So, containers introspect and notify with HTTPSessionBindingEvent.
-Shiva
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic