struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Li Ying <liying.cn.2...@gmail.com>
Subject Re: File Download with multiple files. Design question
Date Sat, 20 Nov 2010 08:45:53 GMT
> Any examples of doing this in struts 2

You can get the HttpServletResponse by:
   ServletActionContext.getResponse()

And then, you can set the download file name, by:
   response.setHeader("Content-Disposition",
		"attachment; filename=" + fileName);

And then, you can get the OutputStream, by:
  response.getOutputStream()

Finally, you can output zipped data to the OutputStream.



> how to "navigate" to the next display after the download?

I believe you can not navigate to the next page.
Because for one http request, the server side can send only one response.
If you want to download file and then show next page, it need 2 responses.
I think this is impossible mission for one http request.

If you send a file download response, then the browser will download
it, and don't refresh the page, which means the current displayed page
will remain.

If you really want to implement this, may be you need some client side
JavaScript to send a file download request first, and then send
another request to display the next page.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message