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 Struts and the fly likes Logging response times 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 » Frameworks » Struts
Bookmark "Logging response times" Watch "Logging response times" New topic
Author

Logging response times

Cindy Jones
Ranch Hand

Joined: Oct 08, 2002
Posts: 66
I have a struts based web application. I need to determine the time spent by a user on each page of the application. This is so I can create a report for each customer who browses through my application with the time he spends on each page. Currently I am planning to extend ActionServlet and include log statements that log start and end of each request as well as the users session id(to nuiquely identify a customer) Is there a standard/better way of doing this?

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Normally the time your server takes to process a request, from start to finish, should be only a few seconds. Now, if I were a user of your system and you told me that I spent 1.377 seconds on page X, I would be bemused, because after your server showed me page X I actually looked at it for a couple of minutes before I clicked on the link to page Y.

So I think you need to clarify what time it is that you are trying to measure.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
It will be tough. You can probably implement some code that will track the time between when a page is shown and when the user clicks a button or link on that page. You won't be able to measure how much of that time the user spent actually looking at the page versus getting a cup of coffee, answering a phone call or the such. Also what if the user never clicks on a link or button?

I know that there are third party products that try and produce these types of metrics. If you needs are sophisticated I would suggest you purchase such a product. If you need something very simple then your general approach seems good (though using a database seems better than a log file).

- Brent
Cindy Jones
Ranch Hand

Joined: Oct 08, 2002
Posts: 66
hiThanks for your responses.
i think my question did not make the actual purpose clear. what i want done is to know how much time i spent serving the different pages to the customers and to track each user session. This is so I know what a particular customer tried to do or when he was actually made to wait a long time.
Currently what I have done is this:
Extended ActionServlet. In this when the request from the first page comes in I create a cookie using System.currrentTime. On each subsequent request that comes in I log the requested uri as well as the cookie value, the start and end time of the request and any other info I have of the customer. This way I know what requests were made by a particular customer and what time he had to waif after each request.
Please let me know if there is a better way to do this.
Thanks,
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Logging response times
 
Similar Threads
Adv & DisAdvantage of using Log4j
User Access permission through API
Proxy problem or cookie disable
IBM ICE Question - Domain Expert
Logging the time it takes for a page to load