Issue
I have two servlets in my application, i want to show the content of both of them, so i did this:
<servlet>
<servlet-name>DisciplinaService</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.lab4.club.main.MiApp</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>SocioService</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.lab4.club.main.MiApp</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>DisciplinaService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SocioService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
When i enter '../disciplinas' or '../socios', i get a 404 error. However, if i only have one servlet mapped, like this:
<servlet>
<servlet-name>DisciplinaService</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.lab4.club.main.MiApp</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>DisciplinaService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
It works with no problem.
Can anyone help me to show both servlets? The problem is in web.xml, i don't know how two show more than one servlet. Notice that i am not using spring or maven.
Solution
your servlet-mapping
shouldn't be the same for both servlet,
Try to map each servlet to different url patterns.
<servlet-mapping>
<servlet-name>DisciplinaService</servlet-name>
<url-pattern>/disciplina/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SocioService</servlet-name>
<url-pattern>/socio/*</url-pattern>
</servlet-mapping>
Answered By - Gal Shaboodi