I have a servlet with web.xml
as follows:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<welcome-file-list>
<welcome-file>/</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>com.mydomain.myapp.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/</url-pattern>
<url-pattern>/rest1*</url-pattern>
<url-pattern>/rest2*</url-pattern>
<url-pattern>/rest3*</url-pattern>
</servlet-mapping>
</web-app>
Ultimately, the servlet should support REST calls like GET
from http://myserver/myapp/rest1?param=1
.
However, what happens is that all invocations of URLs that start with http://myserver/myapp/
from a browser apparently lead to calls to the servlet's doGet()
method with request.pathInfo() == null
.
But then, with the given url-pattern
s, should the URL http://myserver/myapp/rest1?param=1
not lead to "/rest1".equals(request.pathInfo())
and should a URL pattern such as http://myserver/myapp/foo
not lead to HTTP response 404 from the servlet?
The servlet is running on Apache Tomcat 9.