Multiple listeners in web.xml?

stivlo picture stivlo · Jul 17, 2011 · Viewed 28.3k times · Source

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>

Answer

Sean Owen picture Sean Owen · Jul 17, 2011

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.