سؤال

I am talking about pure servlet application (assuming no framework is used). Which Servlet Listener does not need to be configured in web.xml? and why? Thanks.

هل كانت مفيدة؟

المحلول

HttpSessionBindingListener are not registered in the DD.. It just happens automatically.. The HttpSession object should take care of this itself.. The HttpSession implementation should work something like the following:

public void SetAttribute( String name, Object value ) {  
   if( value instanceof HttpSessionBindingListener ) {  
   // Build HttpSessionBindingEvent  
   value.valueBound( event );  
 }  

  // Do the rest  
 }  

نصائح أخرى

The listener HttpSessionActivationListener is not needed to be configured in web.xml. Although I do not know the exact reason why it need not be configured, I think it deals with session activation and passive events when the session is being migrated from one JVM to another JVM.

You can refer javadoc for HttpSessionActivationListener

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top