I need to do a lot of background work in my jsp and i do not want to keep my client waiting. Hence i want to redirect my client to main menu page and continue with my processing. Is it possible to implement this using multi-threading in a JSP?

Jayaprakash A

Well, you can use another work around, but only in a specific case. What kind of processing do you in the back ground? Do you want to send some response back to the user once u finish the background process? If that is not the case, and you want to finish the process silently in the background without letting the user know, you can follow this way. When you use reponse.sendRedirect(), even though the user is redirected to a different page, the service method of that servlet or JSP will gets executed. So, redirect the user to the page u want and have all the other code for background processing after that line. Like this,

response.sendRedirect("targetpage.html");
// Do all the bg processing after this.
//

So, all that code will be executed. But, if you try to write anything again to that reponse, it will throw an IllegalStateException.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact