wood burning stoves 2.0*
The moose likes Struts and the fly likes Forwarding after response committed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Forwarding after response committed" Watch "Forwarding after response committed" New topic
Author

Forwarding after response committed

pamir sonmez
Ranch Hand

Joined: May 31, 2010
Posts: 47
I have an action method that is called from a jsp page,




When file is written to the response, dialog-box appears and I save file to my local computer.
But the forward does not work since;


Since I wrote to the response I can not forward after that.
Is there any possibility that I can forward this request to the another page?
Or can you suggest another way of implementing this function?
(i.e save file to the session and redirect another page etc....)

Thanks
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

The general approach is that you open a page first in the browser and the browser will then call this action to get the report file. So basically instead of calling this action directly, you'll show a web page in the browser. After the web page completes loading, it will redirect the browser to this action (look here to know how to do this). This way the user will see a web page and then the download will begin. You'll not need to store the report in session too which will save server memory. In your action you'll return null so that after the report is sent the action won't try to forward to any JSP page...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
pamir sonmez
Ranch Hand

Joined: May 31, 2010
Posts: 47
I could not understand what you mean exactly

Ankit Garg wrote:The general approach is that you open a page first in the browser and the browser will then call this action to get the report file. So basically instead of calling this action directly, you'll show a web page in the browser.

In a jsp page, there is a button , when I clicked it action is called


Ankit Garg wrote:
After the web page completes loading, it will redirect the browser to this action (look here to know how to do this). This way the user will see a web page and then the download will begin.

In action method, when I created the file, if I dont write it to the response, how will user download it?
Or I have to save it to the session?


Ankit Garg wrote:
You'll not need to store the report in session too which will save server memory. In your action you'll return null so that after the report is sent the action won't try to forward to any JSP page...


Will be another action method?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forwarding after response committed