Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Liutauras Vilda
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Devaka Cooray
Paul Clapham
Saloon Keepers:
Scott Selikoff
Tim Holloway
Piet Souris
Mikalai Zaikin
Frits Walraven
Bartenders:
Stephan van Hulst
Carey Brown
Forum:
Java in General
genarate PDf and save it on server
Harshal Gurav
Ranch Hand
Posts: 151
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello All,
In My web application,I am creating pdf files using itext. I need to save it on my server folder on below folder
my allication path is
http://SampleApp/PDFstore/test.pdf
When i try to given above path in code for genarating pdf, it is not working
Could you please suggest ?
try { String path='' OutputStream file = new FileOutputStream(new File("http://SampleApp/PDFstore/test.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); document.add(new Paragraph("Hello Kiran")); document.add(new Paragraph(new Date().toString())); document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); }
James Boswell
Bartender
Posts: 1051
5
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You need to take a look at the API for files, IO etc. You don't create a file by passing a URL
string
to it.
For your specific requirements, you need to save the file to disk using either a relative or absolute path.
Tim Moores
Bartender
Posts: 7645
178
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You need to use a
file:///
URL. Note that a web app has no notion of a default directory, so you need to convert your relative path to an absolute path. The
servlet
API contains methods that can help you do that in the ServletContext interface.
Harshal Gurav
Ranch Hand
Posts: 151
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks James and Time,
Tim, Could you please more elaborate your help
The servlet API contains methods that can help you do that in the ServletContext interface.
Tim Moores
Bartender
Posts: 7645
178
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Have you looked at the ServletContext javadocs? Which method may I have had in mind?
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
problem in generating multiple pdf docs on the fly from a servlet
printing with iText
Cannot forward after response has been committed? PDF save in Browser?
Web Remoting + Problem with file download
Cannot forward after response has been committed? PDF save in Browser?
secure pdf view
More...