How can two web applications use same Servlet in Tomcat

301 Views Asked by At

I have two web applications. Both needs to use the same Servlet which is in a .jar that is under Tomcat /lib directory.

What should I do to achieve this?

In web.xml of one web application there is this:

<listener>
    <listener-class>org.jwebsocket.tomcat.ContextListener</listener-class>
</listener>
<servlet>
    <servlet-name>jWebSocket</servlet-name>
    <servlet-class>org.jwebsocket.tomcat.TomcatServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>jWebSocket</servlet-name>
    <url-pattern>/jWebSocket</url-pattern>
</servlet-mapping>

This works for one web application. What about the other? Simply writing the same in its web.xml, with/without different url-pattern didn't work. With "didn't work" I mean, although it seems to be deployed, it is not started by ContextListener.

0

There are 0 best solutions below