This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes LogServlet Sends response first and then processes request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "LogServlet Sends response first and then processes request" Watch "LogServlet Sends response first and then processes request" New topic
Author

LogServlet Sends response first and then processes request

Haarshal Kul
Greenhorn

Joined: Sep 01, 2011
Posts: 3

I have a servlet that receives the post http request and logs the data in the HTTP body. It does not return anything back and client does not need anything other than HTTP 200 status.

Lately we have seen a lot of delay in this process due to heavy load. Can I just commit the response using either flushBuffer() or PrintWriter flush() and close()?

Are there any disadvantages to that?

Logging process can it's sweet time once the response is sent. Am I thinking right?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

Nope. If you want the long process to happen independent of the response, you'll need to fire it off in its own thread.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Haarshal Kul
Greenhorn

Joined: Sep 01, 2011
Posts: 3

Ok that makes sense. I can spawn threads for these.
Haarshal Kul
Greenhorn

Joined: Sep 01, 2011
Posts: 3

Thanks a lot.
 
GeeCON Prague 2014
 
subject: LogServlet Sends response first and then processes request