Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8839585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:16:10+00:00 2026-06-14T10:16:10+00:00

I’m doing a java web application for a coursework. In this application there are

  • 0

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:

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.<init>(FileOutputStream.java:212)
    java.io.FileOutputStream.<init>(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)

And here is the code I have written:

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);
        }

I’m sure that the code is right and, also, that the folder exists, why can’t I save my file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:16:11+00:00Added an answer on June 14, 2026 at 10:16 am

    This is not an iText question. You will have the same exception if you remove all the iText code and try writing plain text to the FileOutputStream.

    The question submitted by Perneel ‘is it necessary that there is a PDF loaded from the Web’ is very relevant. Why don’t you create the PDF in memory instead of writing it to a file? See the example of chapter 9 in “iText in Action” for inspiration: http://itextpdf.com/book/chapter.php?id=9 (reading the chapter will also help).

    In any case: madth3 is right: you are assuming (1) that the path to \WebApplication\pdf\ exists and (2) that the web application has access to this path. Just create a File object using the path "." and use getAbsolutePath() to write that path to the output of your servlet. I bet it won’t give you the result you expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.