Reputation: 19308
This question is asked before How to make Apache Tomcat accept DELETE method, but the solution it provides doesn't work for me. I've added
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
to web.xml and my <servlet>
setting looks like this:
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
But still, I got 405 when visiting with DELETE
. Any advice? btw I've restarted tomcat.
Upvotes: 0
Views: 3345
Reputation: 5603
Have a look at the source code: Default Servlet
There you can see that a status code 405 Not allowed is returned if the delete call of the web resource failed.
From your question it's not clear what you are trying to delete - it seems that your resource can't be deleted.
The tomcat funcspec states:
On each HTTP DELETE request processed by this servlet, the following >processing shall be performed:
- If modifications to the static resources are not allowed (set by a configuration parameter), return HTTP status 403 (forbidden).
- If an attempt is made to delete a resource from /META-INF or /WEB-INF, return HTTP status 403 (forbidden).
- If the requested resource does not exist, return HTTP status 404 (not found)
- Unbind the resource from the directory context containing the static resources for this web application. If successful, return HTTP status 204 (no content). Otherwise, return HTTP status 405 (method not allowed).
Either the source code or the Functional Specification you can see that the delete method is accepted by the Servlet you simply have to pass an URL to a resource that's actually deletable.
Upvotes: 1