permaculture playing cards
The moose likes Servlets and the fly likes Time taken by a request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Time taken by a request" Watch "Time taken by a request" New topic

Time taken by a request

Ram Jeevi

Joined: Nov 28, 2008
Posts: 7
Hi Team
Is there any method in java to calculate the time taken by a request to travel from browser to server and back to browser. I want to calculate the time taken by each request sent and received.

Thanks in advance

Ram Jeevi
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13024
In order to measure the total travel time you need custom code on the client side to emulate a browser or a specialized browser plugin.

You could use the standard Java library classes in the and packages and the System.currentTimeMillis() method to time a single request/response cycle. If you just want to measure the time in the servlet, ignoring network time, use currentTimeMillis in your doGet etc method.

The Apache HttpClient toolkit could be used for more complex testing.

[ December 12, 2008: Message edited by: William Brogden ]
I agree. Here's the link:
subject: Time taken by a request
jQuery in Action, 3rd edition