I am a beginner, trying to implement a simple CRUD application using jersey. I am trying to delete one row based on the input passed by the user through a web page. But my method is not being called i am getting the following error.
HTTP Status 405 - Method Not Allowed
type Status report
message Method Not Allowed
description The specified HTTP method is not allowed for the requested resource.
This following is my delete function which should delete based on the FormParam it gets through html.
@DELETE
@Path("/delete")
@Produces(MediaType.TEXT_HTML)
public void delEmployeeFormParam(@FormParam("Employee_id") int employee_id){
java.net.URI location= null;
System.out.println("teting");
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Employee_db", "root", "root");
String query = "delete from employee where emp_id = (?)";
PreparedStatement st = con.prepareStatement(query);
st.setInt(1, employee_id);
st.executeQuery();
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
The html code is shown below.
<body>
<h3> Enter Employee Id to Delete </h3>
<div>
<form method="DELETE" action="http://localhost:8080/RESTCRUD/rest/employee/delete">
<p>Employee Id: <input type:"text" name="Employee_id"/></p>
<input type="submit" value="submit"/>
</form>
</div>
</body>
One thing to Note other methods such as GET and POST are working fine.