Programmatically adding a listener to a Spring application?

I follow in this example to configure HttpSessionListenerSpring for my application. Unfortunately, I cannot change any of the XML files, so my problem is the following line:

<web-app ...>
    <listener>
      <listener-class>com.mkyong.SessionCounterListener</listener-class>
    </listener>
</web-app>

Is there a way to add a listener programmatically without modifying any XML file? And if so, how and where to do it?

+4
source share

All Articles