response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
response.setHeader("Pragma", "no-cache"); //HTTP 1.0
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
Long id = Long.valueOf(request.getParameter("id"));
Product product = productManager.get(id);
Response resp = null;
if (product == null) {
resp = new Response(false, "Registro no encontrado");
response.getWriter().append("{");
response.getWriter().append("\"success\":" + (product != null ? "\"OK\"" : "\"FAIL\""));
response.getWriter().append("}");
response.getWriter().flush();
response.getWriter().close();
} else {
try {
resp = new Response();
response.getWriter().append("{");
response.getWriter().append("\"success\":" + (product != null ? "\"OK\"" : "\"FAIL\"") + ",");
response.getWriter().append("\"item\":{" + "\"price\":" + (product.getPrice()) + "," + "\"description\":" + "\"" + product.getDescription() + "\"" + ","
+ "\"unitMeasure\":" + "\"" + product.getUnitMeasure().getDescription() + "\"" + "," + "\"measure\":" + product.getMeasure() + "}");
response.getWriter().append("}");
response.getWriter().flush();
response.getWriter().close();