HTML form only supports GET and POST. To use other HTTP Methods from a web browser, we can use JavaScript Ajax call. In this example we are using JQuery API.
Here's how an HTML Form along with JQuery can be used to make a PUT (and other HTTP methods) request.
$("#the_form_id").submit(function(event){
//disable default form submission
event.preventDefault();
var $form = $(this);
$.ajax({
type : 'PUT',
url : url,
contentType: 'application/json',
data : form_data//should be converted fo json
success : function(data, status, xhr){
//show success message
},
error: function(xhr, status, error){
//show error message
}
});
});
Example Project
Dependencies and Technologies Used:
jersey-core-server 2.22.1: Jersey core server implementation.
jersey-container-servlet 2.22.1: Jersey core Servlet 3.x implementation.
jersey-media-moxy 2.22.1:
Jersey JSON entity providers support module based on EclipseLink MOXy.
jersey-test-framework-provider-jdk-http 2.22.1: Jersey Test Framework - JDK HTTP container.