One possible (some anti-patterns) workaround is this, but it's not a great design, probably
However, I have seen this (and admit that I did it) before, and, except for some guilt, he did the trick
the user clicks the link that goes to the servlet that generates the PDF, and will just wait (timeout settings should be applied) until he is ready ... (Content-Disposition header, etc.), as usual download
Servlet will report the progress of a shared session variable when creating a PDF
AJAX call to the server will read progress from the session variable and show the user
when the PDF is completed, the browser will simply download it (there may be a risk of request timeout)
The main problem here is to use the request stream as a workflow and block it, which may give this answer a couple of downvotes ...
I am not familiar with Message Driven Beans, but this is a different, possibly better solution.
source share