0

I made a PDF in a java class that I want to be downloadable from the browser. I searched some solution online and I found the "servlet solution" but I don't understand how it works, what are request and response, how I generate them and how I can call the protected method. It would be nice if you can help me.

this is the method that generate the PDF (it works)

public void creaPDF(Persona p) throws IOException, DocumentException {
    Document doc=new Document();
    PdfWriter.getInstance(doc, new FileOutputStream("/."));
    doc.open();
    PdfPTable table=new PdfPTable(1);
    table.addCell(p.getCognome());
    table.setHeaderRows(1);
    doc.add(table);
    doc.close();
}

This is my first experience with jsp, servlet and all the other stuff, be patience.

  • My advise: try to get to know each new technology on its own. I.e. first follow some basic tutorial to get a simple servlet running on your server, something producing a simple hello world html output. Experiment around a bit with that setup, and as soon as you feel at home with that technology start integrating external libraries for creating formats like pdf. – mkl Mar 14 '18 at 21:09
  • thanks for the advice. I solved the situation yesterday. – Gianmarco Mucciariello Mar 15 '18 at 08:56
  • If you solved it - please answer your question here. What did you do? So you help all others... – Lonzak Mar 16 '18 at 07:06
  • i followed this suggest https://stackoverflow.com/questions/9391838/how-to-provide-a-file-download-from-a-jsf-backing-bean – Gianmarco Mucciariello Mar 16 '18 at 09:47

0 Answers0