In my work, I'm developing a Java EE application, with web service REST (Jersey), Hibernate and JQuery on the front end. All of my system requests use ajax and I'm having trouble generating the report and displaying it on the screen for the user (either opening it in the browser or downloading it.)
I would like to know the best way to do this, I have seen some sites saying that it is not possible to open the PDF received by Ajax.
I have some filters that the user can choose to generate the report and pass these filters through a POST to the web service that returns me like this (I believe that part is right):
File relatorio = gerarRelatorioExtratoVendas(movimentos, usuarioLogado, filtros);
ResponseBuilder response = Response.ok(relatorio); response.type("application/pdf");
response.header("Content-Disposition", "attachment; filename=" + relatorio.getName());
return response.build();
Now I need to receive it and show it to the user, I'm saving it to a temporary system folder.