File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes creating a new thread from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "creating a new thread from servlet" Watch "creating a new thread from servlet" New topic
Author

creating a new thread from servlet

Anupreet Arora
Ranch Hand

Joined: Jun 17, 2003
Posts: 81
Hi,
I am currently facing a problem with a web application I am supporting.
I actually need to create and show pdf report that is based on the extract of a large amount of data. The extract of the data takes some time and then its formatting and conversion into a pdf report also takes quite some time. The problem is that while the application is doing so, the request times out (currently 2 mins) and the user is takes to a error page.
So we are exploring two options to avoid this problem.
1) Create a new thread from the servlet's service method ( Struts perform method of the action servlet ) which will do the processing for the extract of data and its conversion into a pdf report. And while this is happening, we can send a response to the user.. maybe to a jsp showing the status of the report. When the report has been generated by the separate thread, it will also create a Marker file. The page that was loaded will keep checking for the existence of the marker file. When found, it will load the report into the browser. The process of extract involves calls to EJBs which give calls to methods to connect to database using connection pool, and then extract the data. The pdf is created using third party java API.
My question is that is there any reason why this should not be done... beacause it is usually said that new threads should not be created from servlets. What are the pitfalls of doing this ?
2) Are there any problems with increasing the request time out parameter to say 15 minutes. The report will be generated in that much time comfortably and no error page will be shown to the users.
3) Is there any other approach that anyone will like to suggest for this issue ?
Regards,
Anupreet
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12753
    
    5
Exactly this sort of question comes up all the time here - browse around in the older posts or do a search and you are bound to find an extensive discussion.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating a new thread from servlet
 
Similar Threads
Need Solution for accesing Action servlet only on Submit
request time out
Dynamic jasperReport on Single jsp
Threads within Struts framework
Client status update after PDF generation through servlet.