-
How To d/l pdf in struts (2 messages)
- Posted by: shaun chettiar
- Posted on: March 03 2008 02:31 EST
Hey, I am using struts 1.3.8 and have a problem that when the user clicks on a link an action is called in which i have to create a pdf file send to user for download and then redirect him to another page (both in the same click). The problem i am facing is that after i generate the pdf and send him on an output stream (ServletOutputStream) the new page is not displayed and it throws a response already committed error. Can anybody please help me in this regards how do i achieve this. Thanks a lotThreaded Messages (2)
- How To d/l pdf in struts by Johnny Zetterstrom on March 11 2008 11:53 EDT
- Re: How To d/l pdf in struts by Sarath Chandra on March 12 2008 12:10 EDT
-
How To d/l pdf in struts[ Go to top ]
- Posted by: Johnny Zetterstrom
- Posted on: March 11 2008 11:53 EDT
- in response to shaun chettiar
Your problem is that you only have one response for one request, so you cannot both write a PDF and also redirect in the same response. A solution could be to send the user to a page that has two links: One for the PDF and one for the page you want to show after the download. The link for the PDF has target="_blank" to open in a new window. Then you submit both links using javascript, which means the PDF download will start in a separate window and the next page will be shown in the same window. If you need a general file management module in your Java web application, may I recommend JEExplorer: http://www.webworks.dk/jeexplorer Which, incidentally, we develop. -
Re: How To d/l pdf in struts[ Go to top ]
- Posted by: Sarath Chandra
- Posted on: March 12 2008 12:10 EDT
- in response to Johnny Zetterstrom
I would rather send the user to the new redirect page with some PK of the pdf as a parameter - first. and call the pdf download action as a redirect from that page Click -> redirect page (Thank you) -(meta/js redirect)-> pdf download