File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Response Header for PDF? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Response Header for PDF?" Watch "Response Header for PDF?" New topic
Author

Response Header for PDF?

Ryan Forman
Greenhorn

Joined: Sep 20, 2006
Posts: 1
I set the response header in my code as follows:

response.setHeader("Content-disposition", "attachment; filename=" + reportName);

If I remove "attachment" from the line above, the PDF will display in the browser. If I leave the code as-is, then the user is prompted to either save or view the PDF. If the user chooses to view the PDF, the PDF is displayed in Acrobat. I would like to find a middle ground. I would like to prompt the user to either save or view the PDF, however; if the user chooses to view the PDF, I would like to display it in the browser...not in seperate Acrobat. Is this possible? How? Thank you for the help.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
You can't. Either you force a save-as prompt like that or let the browser decide what to do.
In the latter case the browser will display the PDF in some way if it can (meaning it has a PDF reader plugin or built-in capability) and otherwise will prevent a prompt asking the user what to do.

PS, this has nothing at all to do with Java per se.


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Response Header for PDF?