Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep a HttpServletRequest alive for an Excel Download

Tags:

servlets

I send a request to the server initiating the creation of an Excel-Workbook. The problem is the request times out when I process a lot of data. I send the Excel-Workbook back via the ServletOutputStream of the HttpResponse.

I tried using the PrintWriter of the Response to keep the Request alive but that takes me to another Page, which I don't want. When I write Data to the OutputStream the Excel-File gets corrupted.

Is there anyway to solve this problem in an easy way, or is it going to be quite complicated?

Thanks

like image 677
Kevin Pirolt Avatar asked Jul 23 '26 11:07

Kevin Pirolt


1 Answers

I think you got two options:

  1. Stream the Excel to the client as it's generated. As long as you send data the request won't time out.

  2. If streaming is not possible you could create the file asynchronous and allow download when done

like image 61
DaniEll Avatar answered Jul 27 '26 05:07

DaniEll



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!