This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 60785
    
  65

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LogServlet Sends response first and then processes request
 
Similar Threads
Set Managed Bean property (value) without user interaction
How to use Threads in Servlets?
Faces Context null in serveResource Request
Sending a http-request without waiting for response
an unnatural act