File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes PDF Download - Outputstream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "PDF Download - Outputstream" Watch "PDF Download - Outputstream" New topic
Author

PDF Download - Outputstream

Koketso Mabusela
Greenhorn

Joined: May 06, 2005
Posts: 2
I am using struts and my application downloads data to the browser in a PDF file. To make sure the download was successfull I close the stream or flush it. Now I want to continue with my session by forwarding to another Struts action, unfortunately when the request is closed you cannot do a thing. Is there a way to move to another Structs action in this scenario?

what if you want to give the user a confirmation screen with additional info.


Koketso Mabusela<br />--------------------<br />SCJP - SCWCD - SCBCD
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One possible solution would be to have your action forward to a confirmation page instead of directly returning the PDF file output stream. The confirmation page would list any additional information you want to give, and also provide a link to perform the actual download. In the link, specify target="_blank" so that the PDF is rendered to a new window. Once the user closes the PDF window, your original confirmation page is still available for the user to navigate back to other pages in your application.


Merrill
Consultant, Sima Solutions
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you want it to be more automatic than that, here's another option:

Instead of putting a link on the confirmation page, you could put JavaScript code in the on load method of the <body> tag to open a new window and call the URL for downloading the PDF. That way, to the user it appears as if you've opened both the PDF window and the confirmation window at the same time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PDF Download - Outputstream