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 and forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "pdf and forward" Watch "pdf and forward" New topic
Author

pdf and forward

Jason Pillgrim
Greenhorn

Joined: Oct 23, 2007
Posts: 2
Hi there!
I would like to know if what I'm trying to do is possible...
My goal is to provide a submit button to user that will invoke a struts Action which will generate a pdf document and send it back to him. What I'm doing is to write the document in the response and to change the header mime type. This works great, but what I need to do is to send the user to other page, I mean, he would click the button and he would be presented in another page and he would recieve the pdf document.

Is there a way to get this functionality or di I have a bad nightmare??

Thanks in advance.
Tarun Yadav
Ranch Hand

Joined: Sep 20, 2007
Posts: 134
Well, you can't forward after sending the file to the user. And if you submit/ link to the file servlet, then the page doesn't get displayed, you'll directly get the download dialog box.

I guess, you could forward to a new page where you can use JavaScript to invoke the download servlet; this seems to be a very common design with download sites. Don't forget to give a direct link in case the submit/ redirect/ refresh fails!
Jason Pillgrim
Greenhorn

Joined: Oct 23, 2007
Posts: 2
Thanks Tarun, I think it's a good idea.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: pdf and forward