someone could help me see my error, I am trying to see or save a pdf on the client side, I am new to servlets, I would appreciate any support, thank you This is my code so far
@POST
@Path("reporteComisiones")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public void reporteComisiones (Dtorest2 dtorest2) throws DocumentException, FileNotFoundException, ParseException, IOException
{
Double TotalPositivo = 0.00;
Double TotalNegativo = 0.00;
Double TotalFinal = 0.00;
Date fecha = new Date();
SimpleDateFormat formateador = new SimpleDateFormat("dd-MM-yyyy");
List<DtoOutrest2> lista = serComisiones(dtorest2);
Document document = new Document();
FileOutputStream FOS = new FileOutputStream("C:\reportes\"+dtorest2.persona_id+"-"+formateador.format(fecha)+".pdf");
PdfWriter.getInstance(document, FOS);
document.open();
Paragraph titulo = new Paragraph("Reporte Comisiones",FontFactory.getFont(FontFactory.TIMES_BOLD,20,Font.BOLD,BaseColor.BLUE));
titulo.setAlignment(titulo.ALIGN_CENTER);
document.add(titulo);
Paragraph Indicefecha = new Paragraph("Del "+ dtorest2.FechaIni + "hasta el "+ dtorest2.FechaFin,FontFactory.getFont(FontFactory.TIMES_BOLD,12));
Indicefecha.setAlignment(Indicefecha.ALIGN_CENTER);
document.add(Indicefecha);
document.add(new Paragraph("----------------------------------------------------------------------------------------------------------------------------------"));
document.close();
HttpServletResponse response = null;
InputStream is = new FileInputStream("C:\reportes\"+dtorest2.persona_id+"-"+formateador.format(fecha)+".pdf");
byte[] data = new byte[is.available()];
is.read(data);
response.setContentType("application/pdf;");
response.setHeader("Content-Disposition","attachment;filename="" + dtorest2.persona_id+"-"+formateador.format(fecha)+".pdf";");
response.setContentLength(data.length);
javax.servlet.ServletOutputStream servletoutputstream = response.getOutputStream();
servletoutputstream.write(data);
servletoutputstream.flush();
servletoutputstream.close();
}