title: How to save pdf with java itext
body: <p>I'm doing a java web application for a coursework. In this application there are two type of users: seller and buyer. The buyer can buy a set of stuff and when he does it, I must create a receipt into pdf format; but when I try to buy something tomcat give me this error:</p>
  
  <pre><code>HTTP Status 500 - \WebApplication\pdf\test.pdf (Impossibile trovare il percorso specificato)
  
  type Exception report
  
  message \WebApplication\pdf\test.pdf (Impossibile trovare il percorso specificato)
  
  description The server encountered an internal error that prevented it from fulfilling this request.
  
  exception
  
  java.io.FileNotFoundException: \WebApplication\pdf\test.pdf (Impossibile trovare il percorso specificato)
  
      java.io.FileOutputStream.open(Native Method)
      java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:212)
      java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:104)
      viewer.PdfCreator.createPdf(PdfCreator.java:30)
      servlet.BuyerConfirmationPage.doGet(BuyerConfirmationPage.java:115)
      servlet.BuyerConfirmationPage.doPost(BuyerConfirmationPage.java:61)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  </code></pre>
  
  <p>And here is the code I have written:</p>
  
  <pre><code>try {
              Document document = new Document(PageSize.A4,50,50,50,50);
              PdfWriter.getInstance(document,new FileOutputStream(request.getContextPath() + "/pdf/test.pdf"));
              document.open();
              PdfPTable table = new PdfPTable(5);
              PdfPCell seller_cell = new PdfPCell(new Paragraph("Seller"));
              PdfPCell name_cell = new PdfPCell(new Paragraph("Name"));
              PdfPCell price_cell = new PdfPCell(new Paragraph("Price"));
              PdfPCell UM_cell = new PdfPCell(new Paragraph("UM"));
              PdfPCell quantity_cell = new PdfPCell(new Paragraph("Quantity"));
              table.addCell(seller_cell);
              table.addCell(name_cell);
              table.addCell(price_cell);
              table.addCell(UM_cell);
              table.addCell(quantity_cell);
              PdfPCell seller_cell_value = new PdfPCell(new Paragraph(seller));
              PdfPCell name_cell_value = new PdfPCell(new Paragraph(name));
              PdfPCell price_cell_value = new PdfPCell(new Paragraph(total_price));
              PdfPCell UM_cell_value = new PdfPCell(new Paragraph(UM));
              PdfPCell quantity_cell_value = new PdfPCell(new Paragraph(quantity));
              table.addCell(seller_cell_value);
              table.addCell(name_cell_value);
              table.addCell(price_cell_value);
              table.addCell(UM_cell_value);
              table.addCell(quantity_cell_value);
              document.add(table);
              document.close();
  
  
          } catch (DocumentException ex) {
              Logger.getLogger(PdfCreator.class.getName()).log(Level.SEVERE, null, ex);
          }
  </code></pre>
  
  <p>I'm sure that the code is right and, also, that the folder exists, why can't I save my file?</p>