Question

I have to create and download the excel file using struts1.3, here i have created excel file dynamically and downloaded successfully, after file download i need to forward to some other page like success page, but it is not forwarding(mapping.findforward("success")) from struts Action class. Please help me to solve this issue.

Thanks, siva.

Was it helpful?

Solution

What you want to do is send 2 response for a single request :

  1. The excel file to be downloaded
  2. The success page.

Technically that is not possible. If you commit your stream by downloading a file, that would mark the end of the request.

There are a couple of workarounds for this requirement:

  1. Show the success page and a link where the user can download the excel file
  2. Show the success page and through an onload script trigger a form submit enabling the user to download the file without any additional clicks.

In both situtations you MUST first show the success page and then download the image. An alternate solution for this problem could be to use Ajax (however I am not sure if that is acceptable).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top