2 Replies Latest reply on Dec 16, 2011 12:34 PM by Emir Calabuch

    FacesContext responseComplete + response sendRedirect

    Ricardo Gomes Newbie

      Hello all,

      I would like to download a file AND redirect to a page.

      If I use the code bellow it does not enable file download, just if I remove the second line. But in this case, it does not redirect.


      Does anyone have any suggestion?

      Ricardo Gomes

        • 1. Re: FacesContext responseComplete + response sendRedirect
          Daniel Serva Newbie

          Hi Ricardo.
          Did you get to solve this problem?
          I'm having a similar issue.
          My download only works once and don't know why.

          Any help?

          Daniel Serva

          • 2. Re: FacesContext responseComplete + response sendRedirect
            Emir Calabuch Newbie

            You cannot download and redirect at the same time, this is simply a limitation of the HTTP protocol (it has nothing to do with Seam or JSF): when processing a request either you provide a single response (a webpage or a download) or you redirect to another resource. You cannot do both at the same time.

            Possible workarounds for this issue are:

            1. Open download in a separate browser window (using an onclick javascript action). This does not work if javascript is disabled. This also requires you to have a RESTful link to the file you're trying to download.

            2. Serve response with a <refresh> meta tag (that makes the page reload). On refresh, issue the response. This also requires javascript, I think (I have never used this solution).

            3. Redirect and serve download file from an iframe embedded in the redirected-to page. This is my preferred solution, as it does not require javascript.