Error in DELETE method, to delete a data from a table


I'm trying to make a method to delete an entry from a table with Java and jsp , but it's giving 405 error. I'll append the codes.

public void remove(Produto produto) {

public Produto busca(Produto produto) {
    return em.find(Produto.class, produto.getId());

public void remove(Produto produto){


<div class="row">
    <form action="<c:url value='/produto/remove'/>" method="DELETE">
        <div class="col s4">
            REMOVER PELO ID:<input type="text" />
        <div class="col s4 right">
            <input type="submit" class="btn waves-effect waves-light btn-large right" value="REMOVER"></input>

And the error that appears is as follows:


HTTP Status [405] - [Method Not Allowed]


Type Status Report


Description The method received in the request-line is known by the   origin server but not supported by the target resource.

asked by anonymous 20.06.2017 / 21:59

2 answers


The method is right. The error was in the JSP form. The correct one is as follows:

<form action="<c:url value='/produto/remove?id=${}'/>" method="POST">
        <input type="hidden" name="_method" value="DELETE" />
    <div class="col s4 right">
        <input type="submit" class="btn waves-effect waves-light btn-small right" value="REMOVER"></input>

Then I passed the button next to the line in the table, so it would pick up the automatic id. Later I can make an input text to pass the id to remove, but at first I'll leave it like this.

21.06.2017 / 17:28

What is the path of the controller? From what I've seen, you have to check if the @Path on the controller is correct and the delete method is correct. Try to use @DELETE, it's easier to read.

20.06.2017 / 23:16