我正在使用 ajax 向我的 servlet 发送请求以生成报告。
报告正在生成,但我想在浏览器中显示它
这是我请求的ajax代码
$.post('servleturl',{
from : from,
to : to
},function(data){
// What should I write here in order to display report in browser
});
我的小服务程序代码
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);