This week's giveaway is in the Java/Jakarta EE forum.
We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line!
See welcome thread
Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can we open local PDF files on jsp onclicking URL in jsp  RSS feed

Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am running web application on server machine.
In web application, i am creating pdf file using itext and saving it on folder c:/PdfFilepath/

I am trying to open this PDF from my web application like : http://localhost:8080/Reportgenarate/showCert.jsp

i am accessing in following fashion:
String path="file:///C:/PdfFilepath/nargi.pdf";

also try with following fashion

When i try to open it from ablove like in firefox, it shows an error like :
firefox doesn't know how to open this address because the protocol

I also installed LocalLink 0.5 add on for firefox. it doesnot work

I am awaire that commons-fileupload-1.2.2 jar is best option to upload file on the server and access it

My application require it should access from c:/PdfFilepath/nargi.pdf

any suggestion is highly appreciate

Author and ninkuma
Posts: 66427
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course not. The file protocol looks for the file on the local file system. So your users would need to already have that file on their own systems. That doesn't make any sense, does it?

If you want to serve the file you'll either need to place it within the web application so that it can be addressed via URL, or write a servlet that will read the file and stream it as the response, setting the appropriate headers.
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
ScroogeXHTML 7.2 - RTF to HTML5 / XHTML converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!