Using AJAX, I am able to post data from my JSP page to my servlet.
$.ajax({
url: 'myServlet?action=FEP',
type: 'post',
data: {machine: i, name: txt}, // where i and txt hold certain values
success: function (data) {
alert('success');
}
});
In my Servlet code:
String jspAction = request.getParameter("action");
//...
if(jspAction.equals("FEP")){
int idMachine = Integer.parseInt(request.getParameter("machine"));
String name = request.getParameter("name");
double value = actions.getValue(idMachine, name); //<-- the value I want to send back to the JSP.
}
The data is sent successfully. However, I am currently unsure of how to return the value
back to the JSP page.