jQuery in Action, 3rd edition
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "PDF Download - Outputstream" Watch "PDF Download - Outputstream" New topic

PDF Download - Outputstream

Koketso Mabusela

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.

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
It's not a secret anymore!