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 REST with Spring (video course) this week in the Spring 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: 42959
You need to set a Content-Disposition header, something like this:

response.setHeader("Content-Disposition", "attachment; filename=\"my-awesome-content.pdf\"")
It is sorta covered in the JavaRanch Style Guide.
subject: File from database save as pdf
It's not a secret anymore!