Hey Guys! Posting here after a real long time.Well i need your advice.We want to create a asynchronous reporting module where in the JSP will call the servlet for a report to be displayed, the servlet should somehow start a seperate process for calling another servlet which will actually connect to DB and build a html page for the report. Meanwhile the JSP should not time out, the first servlet ought to return the control back to the JSP which should keep polling this servlet for a status(if the report is done) once the second servlet is finished the first servlet should change the status and JSP should then redirect to the html page generated for the report. Hope im able to make sense out of what im trying to say. The thing i want to know is that is there a way we can seperate the incoming request from the JSP-ie the control should goback to the jsp to wait meanwhile the same request object should be passed to the second servlet which will process it. We were thinking of writing a thread which can spawn the second process but that doesnot seem to be a very good idea since this thread would be running in the servlet container. All ideas welcome Thanks! Daman
I think RequestDispatcher can play an important role in your problem... Have you tried it? I'm not very clear about your problem... Is it like parallel processing on resources? If so, we need to find another approach, rather than just using RequestDispatcher...
Originally posted by Pradeep Bhat: Ko, How will it help? Isnt that synchronous?
:roll: I dunnoe, I'm not quite clear with daman sidhu's situation...
Joined: Aug 19, 2000
hi.. well the situation was that we needed to run a asynchrounous process..normally all the requests to the servlets are synchrounous ie the response is immediate and its a online sort of thing.. we needed the request to start a process and come back later when its done and pick up the result.. we have decided today how to do it- well be starting a seperate thread which will process whatever needs to be done(its basically passing some info to other servlet using URLConnection which will create a report and dump the output back),this thread will be stored in the users session(tho that may not sound very good-but it will work) and the jsp will keep pinging the servlet which will check this thread object-if its done with the processing it can redirect the user to the dumped report output page Will code it and run it and let u guys know if it worked thanks for the suggestions Daman
Hi Kyle, First of all thanks for your reply appreciate getting tips from you specially. Well we had considered JMS as an option too cause thats what the specs say should be used for asnychronous behaviour, but later decided on this-the reason being we would have the learning curve for the same plus the guys here want the thing to be done pretty fast.. but ill try and suggest it again to the team and see what happens thanks for the help again Regards, Daman
If your team knows EJBs, the should know Message Driven Beans. Also I think that the Message Driven Bean implementation isn't that difficult to understand. I know in Apress's Enterprise Javabeans book, they have a really good section on Message Driven Beans and how to create them. It seemed pretty easy to me when reading about it. I think that this is your best solution. Now on another idea, why don't you have this Message Driven Bean create the report then e-mail it back to the user, then the user can do anything they want right after sending in the request, even going to a completely unrelated web site. My 2 cents, from book reading. Mark
Originally posted by daman sidhu: Hi Kyle, First of all thanks for your reply appreciate getting tips from you specially. Well we had considered JMS as an option too cause thats what the specs say should be used for asnychronous behaviour, but later decided on this-the reason being we would have the learning curve for the same plus the guys here want the thing to be done pretty fast.. but ill try and suggest it again to the team and see what happens thanks for the help again Regards, Daman
You're quite welcome, Daman. BTW, I've been working on the side on an implementation of a servlet and MDB that does this so I can officially write it up as a pattern. Perhaps this is something for December or January's JavaRanch Journal?
Joined: Aug 19, 2000
Wow! That will be cool Kyle, will be looking fwd to that implementation! Mark,thanks for the suggestion, but in the current scenario we have to display the report on the web page itself.We are using a 3rd party reporting tool called web focus to generate reports.This tool has a servlet interface with which we interact to generate reports. So the reports have to be shown on the browser itself,but the user should have the option to surf other links on the site and when the report is done(in the background) it should pop up for him. MDB's may be a good option but then again using EJB's is currently ruled out. Am using the thread implementation only,will post up the code once im done. Thanks guys!Appreciate the help Daman