This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes genarate PDf and save it on server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "genarate PDf and save it on server" Watch "genarate PDf and save it on server" New topic
Author

genarate PDf and save it on server

Harshal Gurav
Ranch Hand

Joined: May 29, 2008
Posts: 151

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 ?
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: May 29, 2008
Posts: 151
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
Have you looked at the ServletContext javadocs? Which method may I have had in mind?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: genarate PDf and save it on server