I have my index.html that has a certain view, and I want to update this view (without redirecting or reloading the page) by calling a java method, that consumes a w
One approach is to expose your Java functionality as a REST service.
Jersey REST end point
@Path("/rest/emp/")
public class EmployeeService {
@GET
@Path("/{param}")
public EmployeDTO getMsg(@PathParam("param") String id) {
return getEmployeeDetails(id);
}
}
EmployeDTO.java
String name;
String id;
String address;
//getters and setters
index.html
Sample Page
The ID is:
The Employee Name:
The Employee Address:
employee.js
$(document).ready(function() {
$.ajax({
url: "/rest/emp/10" (Your Rest end point URL)
}).then(function(data) {
$('#eid').append(data.id);
$('#eName').append(data.name);
$('#eAddress').append(data.address);
});
});