This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "pdf and forward" Watch "pdf and forward" New topic

pdf and forward

Jason Pillgrim

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

Joined: Oct 23, 2007
Posts: 2
Thanks Tarun, I think it's a good idea.
I agree. Here's the link:
subject: pdf and forward
It's not a secret anymore!