File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes File from database save as pdf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File from database save as pdf" Watch "File from database save as pdf" New topic

File from database save as pdf

Honzak Troubak
Ranch Hand

Joined: Jan 11, 2013
Posts: 31

I don't know how save pdf file from database as pdf file.

I have link

and action (maybe it's mistake but I don't know how make it better)

This action calls method readPaperFile()

When I click on link, I can download file readPaperFile.action (same name like name of action). If I rename file to file.pdf, file will open via Acrobat Reader and everything is great. But I can't save file as pdf type, everytime it is readPaperFile.action.

Does anybody know how resolve it?

Thank you very much
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
You need to set a Content-Disposition header, something like this:

response.setHeader("Content-Disposition", "attachment; filename=\"my-awesome-content.pdf\"")
I agree. Here's the link:
subject: File from database save as pdf
It's not a secret anymore!