I need to create a PDF file dynamically
using the data from the database, it might take from 5 sec to 10 min. Meanwhile, I don't like to wait idle, any solution?
any help appreciated!!
I can think of two solutions. One is pure J2EE and the other is a browser trick.
1. Use a Message Driven Bean. Your Web App dumps a message into a queue which is processed async.
2. Have your web page call to the server using an XMLHttpRequest. This can be done so that it looks asynch, but is still synchronous from the web app.
for your first solution, if I use a MDB to process the message and generate a PDF file, how could I notify the web application that "the PDF is created, please display it"?
thank you for your help!!
We do exactly this in our application. We have 2 options for the user:
User requests PDF generation servlet.
Servlet flushes HTML 'waiting' message to user (while still generating).
When PDF is ready, PDF file is written to unique URL and final flush to browser includes meta-refresh to new unique URL.
Client gets first response flush 'waiting' message, second response flush redirect to finished file.
The other option is for users to request PDF document generation and be notified by email when the document is complete.
The email provides the unique URL to access the PDF.