aspose file tools
The moose likes Servlets and the fly likes LogServlet Sends response first and then processes request Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply 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: 56202
    
  13

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: LogServlet Sends response first and then processes request
 
Similar Threads
How to use Threads in Servlets?
Faces Context null in serveResource Request
an unnatural act
Set Managed Bean property (value) without user interaction
Sending a http-request without waiting for response