Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple listeners in web.xml?

How do I specify multiple listener classes in web.xml? I tried searching the web without luck.

I tried the following, but it seems that it doesn't work:

<listener>
    <listener-class>
        org.obliquid.web.StartAndStop
    </listener-class>
</listener>
<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
like image 407
stivlo Avatar asked Jul 17 '11 11:07

stivlo


People also ask

What is the use of listener in web XML?

Servlet Listener is used for listening to events in a web container, such as when you create a session or place an attribute in a session or if you passivate and activate in another container, to subscribe to these events you can configure listener in web. xml, for example, HttpSessionListener.


1 Answers

That is the correct syntax. What "didn't work"? It's not this bit, unless perhaps you mean there's an XML parsing error because it's in the wrong place in the doc.

EDIT: the 'right' place if I recall correctly is before <servlet> but I am not sure if the latest XSD schemas do restrict that. You would get a clear parsing error if this was the problem.

like image 158
Sean Owen Avatar answered Sep 22 '22 19:09

Sean Owen