我正在使用ajax向我的servlet发送请求以生成报告。
报告已生成但我想在浏览器中显示
这是我的请求的ajax代码
$.post('servleturl',{
from : from,
to : to
},function(data){
// What should I write here in order to display report in browser
});
我的servlet代码
OutputStream outputstream = response.getOutputStream();
//This line converts the report to PDF
report.toPdf(outputstream);
outputstream.close();
//Converting the outputstream to JSON to pass as response
json = new Gson().toJson(outputstream);
response.setContentType("application/json");
response.getWriter().write(json);